-1

I use Lightbox2 on my website, I found it to be the best gallery according to my taste but there is one problem remaining : I hate not having the swipe support for mobile devices... this is frustrating for users.

Does anybody knows how to add swipe gesture support to Lightbox2 plugin?

Regards

Gargovan
  • 11
  • 1

1 Answers1

1

I use Hammer.js library to perform the swipe functions. First add Hammer library to your site: hammerjs on github Secondly add the jquery.hammer.js function to your site. Github location: Github

At last add the jquery scrip code to your site:

$('#lightbox').hammer().on("swipe", function (event) {
                if (event.gesture.direction === 4) {
                    $('#lightbox a.lb-prev').trigger('click');
                } else if (event.gesture.direction === 2) {
                    $('#lightbox a.lb-next').trigger('click');
                }
            });
Magni Hansen
  • 82
  • 10
  • Where do you put this code? The div #lightbox is not existent when loading the window. It is created when opening the lightbox... – Marc Aug 17 '18 at 08:47