Skip to content

Commit

Permalink
_sharedListener as protected property
Browse files Browse the repository at this point in the history
  • Loading branch information
valdrinkoshi committed May 30, 2017
1 parent 5f668fb commit bd41590
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions iron-overlay.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ <h2>Hello world!</h2>
(() => {
'use strict';

const sharedListener = new Polymer.SharedEventListener();
const contentHostGenerator = new Polymer.ScopingHostGenerator('iron-overlay-content-host');

class IronOverlay extends Polymer.Element {
Expand Down Expand Up @@ -169,15 +168,36 @@ <h2>Hello world!</h2>

/**
* The host of the content.
* @type {Element|DocumentFragment}
*/
contentHost: {
type: Element,
type: Object,
readOnly: true
},

/**
* The node where focus should be restored once the overlay is closed.
* Focus will be restored there only if nothing else is focused (e.g. if user
* clicked another button and overlay got closed, we don't restore focus).
* @type {Node}
* @protected
*/
_restoreFocusNode: {
type: Node,
type: Object,
value: null
},

/**
* A shared event listener to handle interactions like tap or keydown.
* The last overlay opened will be the last to listen for events, but should
* be the first to handle the event. The shared event listener allows this, delegating
* the handling of the event to the last one listening for it.
* @protected
*/
_sharedListener: {
type: Object,
readOnly: true,
value: new Polymer.SharedEventListener()
}
};
}
Expand Down Expand Up @@ -286,11 +306,11 @@ <h2>Hello world!</h2>
*/
_toggleListeners() {
if (this.opened) {
sharedListener.listen('tap', this, '_onTap');
sharedListener.listen('keydown', this, '_onKeydown');
this._sharedListener.listen('tap', this, '_onTap');
this._sharedListener.listen('keydown', this, '_onKeydown');
} else {
sharedListener.unlisten('tap', this);
sharedListener.unlisten('keydown', this);
this._sharedListener.unlisten('tap', this);
this._sharedListener.unlisten('keydown', this);
}
}

Expand Down

0 comments on commit bd41590

Please sign in to comment.