-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added escape listener for closing the full screen popup #49
base: master
Are you sure you want to change the base?
Conversation
e.preventDefault(); | ||
} | ||
} | ||
document.addEventListener('keyup', this._events.escapeListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use assignEvent from the util, which returns a method to remove event.
You can do
this.__events.onEscape = assignEvent(document, 'keyup', this._events.escapeListener);
and in hide method you can just call.
this.__events.onEscape();
@@ -101,6 +104,14 @@ function (_ImageViewer) { | |||
this.load(imageSrc, hiResImageSrc); | |||
} // handle window resize | |||
|
|||
// escape listener | |||
this._events.escapeListener = (e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._events holds the removeListener methods, don't add listener there. See below. This will give error when you do viewer.destroy()
@@ -69,6 +69,9 @@ function (_ImageViewer) { | |||
display: 'none' | |||
}); // enable scroll | |||
|
|||
// escape listener | |||
document.removeEventListener('keyup', _this._events.escapeListener); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all changes should be on source file. Lib is the generated file.
Do we want to make this an option, or just on by default?