I have an image carousel and an image gallery lightbox, both of which allow users to swipe through photos. However, there is also a swipe event on the entire body of the page, to open a side panel.
I've tried using the below code on the child gallery elements, but the swipe events are still bubbling to the body of the page and opening the panel.
If anyone knows what I am doing wrong, any advice is much appreciated!
$('.lightbox, .carousel').bind('swipeLeft swipeRight', function(event) {
event.stopPropagation();
event.preventDefault();
event.stopImmediatePropagation();
});
Here's the fiddle.
Source
You need to use
swipeleft
andswiperight
(note not capitalL
orR
). You have the correct capitalisation in your menu opening binding however.JSFIDDLE