jsOnlyLightbox icon indicating copy to clipboard operation
jsOnlyLightbox copied to clipboard

Add touch/swipe support

Open felixhagspiel opened this issue 9 years ago • 2 comments

felixhagspiel avatar Mar 09 '15 15:03 felixhagspiel

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');
        }
    });





})();

milanffm avatar Dec 01 '15 09:12 milanffm

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

felixhagspiel avatar Dec 01 '15 17:12 felixhagspiel