Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amritk
Copy link
Contributor

@amritk amritk commented Jun 5, 2019

Do we want to make this an option, or just on by default?

@amritk amritk changed the title Added back button and escape listeners for closing the full screen popup Added escape listener for closing the full screen popup Jun 5, 2019
e.preventDefault();
}
}
document.addEventListener('keyup', this._events.escapeListener);
Copy link
Owner

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) => {
Copy link
Owner

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);
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants