Skip to content
This repository has been archived by the owner on Nov 21, 2023. It is now read-only.

Close image on ESC or clicking outside #169

Open
rafa-munoz opened this issue Apr 19, 2016 · 5 comments
Open

Close image on ESC or clicking outside #169

rafa-munoz opened this issue Apr 19, 2016 · 5 comments
Assignees
Milestone

Comments

@rafa-munoz
Copy link

It would be nice to have these features:

  • If you click outside the image, you close it. It's a common behaviour now with so many touch devices.
  • If you press the ESC button, you close the photo. Many viewers already implement this feature.

Greetings and thanks!

@terrymun
Copy link
Owner

With regards to user actions that trigger closing:

  • Clicking outside the image already closes it... have you tried that?
  • Escape button (key code 27) is not listened on, but you can manually bind it (using $(document).on('keydown'...)) and then trigger the .close() public function. The reason I chose not to implement this is because it's really up to the developer/designer to decide what kind of user action closes it, but on second thought, maybe I should include it as a default behaviour...

@rafa-munoz
Copy link
Author

Yes, I tried to click outside, but doesn't work at all. Maybe because I have a little bit special layer configuration and needed to customize the behaviour of Fluidbox. Regarding the second point, fair enough, it can be done also by the developer, nothing against about that. But also may be a good idea to include it as a option with default false?

@terrymun
Copy link
Owner

Will keep in view for future usability improvements, but will close this issue for the moment being. Feel free to reopen it if you see the need as such.

@terrymun
Copy link
Owner

After studying the W3C accessibility guidelines, pertaining to the <dialog> behaviour, I have decided that the escape key should trigger Fluidbox close event when pressed on, as it is a standard behaviour expected by end users. This fix will be included in the next minor version update :)

@terrymun terrymun reopened this May 25, 2017
@terrymun terrymun added this to the v2.0.6 milestone May 25, 2017
@designosis
Copy link

This feature is already there (though disabled) on line 609 of Fluidbox/src/js/jquery.fluidbox.js.

Just need to change this ...

    $d.on('keydown', function(e) {

... to ...

    $fb.on('keydown', function(e) {

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

No branches or pull requests

3 participants