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

Turn off grab to close #1277

Closed
Tusko opened this issue Mar 11, 2017 · 8 comments
Closed

Turn off grab to close #1277

Tusko opened this issue Mar 11, 2017 · 8 comments

Comments

@Tusko
Copy link

Tusko commented Mar 11, 2017

Hey!
Can I disable grab up/down to close fancybox window?

@fancyapps
Copy link
Owner

Hi,

To disable touch events, you can either set touch:false using data attribute:

<a data-fancybox data-src="#myElement" href="javascript:;" data-options='{"touch" : false}'>
	Click me
</a>

or when initializing fancyBox:

$('selector').fancybox({
	touch: false
});

If you want to disable only vertical movement, set touch: { vertical : false }

@Tusko
Copy link
Author

Tusko commented Mar 11, 2017

@fancyapps awesome!
Thank you so much!

@Tusko
Copy link
Author

Tusko commented Mar 11, 2017

@fancyapps doesn't work if html uploaded via AJAX
http://azuz.dev0.site/lviv-interactive-map/

try to click on the marker

@fancyapps
Copy link
Owner

My first guess would be that you have mixed ' and ". See the difference:
data-options='{"touch" : false}' - works
data-options="{'touch' : false}" - does not

Confusing, I know, but that is how it works:
https://api.jquery.com/data/#data-html5
https://en.wikipedia.org/wiki/JSON#Data_types.2C_syntax_and_example

@Tusko
Copy link
Author

Tusko commented Mar 11, 2017

@fancyapps awesome2
You're right!

@fancyapps
Copy link
Owner

fancyapps commented Mar 11, 2017

Also, I noticed that header is jumping when opening/closing fancybox.
It is easy to fix, all you have to do:

  1. add "compensate-for-scrollbar" CSS class for your <header> element;
  2. and add "transition: transform 0.5s;" CSS rule to that element, too (this disables margin property animation, but allows animated transforming).

Btw, I like hover animation on buttons, looks nice.

@kamilwronka
Copy link

@fancyapps

Hello! I'd like to ask you a question. I have a problem with touch events in your gallery. The thing is, when my image is zoomed in, swiping vertically is closing the gallery and user can't see full image because of it. Is there any option to disable only closing the gallery when zoomed in?

@Tusko
Copy link
Author

Tusko commented Aug 5, 2019

@kamilwronka
try this:

$('[data-fancybox="gallery"]').fancybox({
    touch: false
});

and don't forget to change [data-fancybox="gallery"] to your selector

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

No branches or pull requests

3 participants