jsOnlyLightbox
jsOnlyLightbox copied to clipboard
Add touch/swipe support
hi added hammerjs for toch/swipe support:
(function() {
var Lightbox = require('./plugins/lightbox');
var LIGHTBOX_OPEN_BOX = '#jslghtbx';
var Hammer = require('hammerjs');
var _lightbox = new Lightbox();
var _hammertime;
_lightbox.load({
onopen:function(){
var _box = document.querySelector(LIGHTBOX_OPEN_BOX);
_hammertime = new Hammer(_box);
_hammertime.on('panend', function(e) {
switch (e.direction) {
case 2:
_lightbox.next();
break;
case 4:
_lightbox.prev();
break;
}
});
},
onclose:function(){
_hammertime.off('panend');
}
});
})();
hey @milanffm thanks for the suggestion! I want to leave 3rd party code out of the lightbox to keep it clean and small, but I will definetly look into hammerjs