From 5cf02d8e6fda20486fd84afb79f0d3555e7bf65c Mon Sep 17 00:00:00 2001 From: t-f-m Date: Thu, 27 Sep 2018 01:10:18 +0900 Subject: [PATCH 1/2] Close gallery when swipe vertically Add feature(gallery): jquery.detect_swipe.js and hammer also support swipeup and swipedown. --- src/featherlight.gallery.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/featherlight.gallery.js b/src/featherlight.gallery.js index cd5793c5..33278294 100644 --- a/src/featherlight.gallery.js +++ b/src/featherlight.gallery.js @@ -39,7 +39,9 @@ if (self._swiper) { self._swiper .off('swipeleft', self._swipeleft) /* See http://stackoverflow.com/questions/17367198/hammer-js-cant-remove-event-listener */ - .off('swiperight', self._swiperight); + .off('swiperight', self._swiperight) + .off('swipeup', self._swipeup) + .off('swipedown', self._swipedown); self._swiper = null; } return _super(event); @@ -55,7 +57,9 @@ if (swipeAwareConstructor) { self._swiper = swipeAwareConstructor(self.$instance) .on('swipeleft', self._swipeleft = function() { self.$instance.trigger('next'); }) - .on('swiperight', self._swiperight = function() { self.$instance.trigger('previous'); }); + .on('swiperight', self._swiperight = function() { self.$instance.trigger('previous'); }) + .on('swipeup', self._swipeup = function() { $.featherlight.close(event); }) + .on('swipedown', self._swipedown = function() { $.featherlight.close(event); }); self.$instance .addClass(this.namespace+'-swipe-aware', swipeAwareConstructor); From 734eef8ec829825daa17dfe4f6397c19abb96c53 Mon Sep 17 00:00:00 2001 From: t-f-m Date: Sun, 30 Sep 2018 01:06:58 +0900 Subject: [PATCH 2/2] Fix: PR #369 Close gallery when swipe vertically fix reviewed point: use argument --- src/featherlight.gallery.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/featherlight.gallery.js b/src/featherlight.gallery.js index 33278294..132eb59f 100644 --- a/src/featherlight.gallery.js +++ b/src/featherlight.gallery.js @@ -58,8 +58,8 @@ self._swiper = swipeAwareConstructor(self.$instance) .on('swipeleft', self._swipeleft = function() { self.$instance.trigger('next'); }) .on('swiperight', self._swiperight = function() { self.$instance.trigger('previous'); }) - .on('swipeup', self._swipeup = function() { $.featherlight.close(event); }) - .on('swipedown', self._swipedown = function() { $.featherlight.close(event); }); + .on('swipeup', self._swipeup = function(event) { $.featherlight.close(event); }) + .on('swipedown', self._swipedown = function(event) { $.featherlight.close(event); }); self.$instance .addClass(this.namespace+'-swipe-aware', swipeAwareConstructor);