Skip to content

Instantly share code, notes, and snippets.

@dariygray
Forked from thiagoeliasr/swiper-magnific-popup.js
Created February 22, 2019 12:06
Show Gist options
  • Save dariygray/3c8e0e24fd0b79ff55ce34f4926d9f60 to your computer and use it in GitHub Desktop.
Save dariygray/3c8e0e24fd0b79ff55ce34f4926d9f60 to your computer and use it in GitHub Desktop.
Adding swipe support to Magnific Popup galleries. (touchSwipe is required: http://labs.rampinteractive.co.uk/touchSwipe/demos/)
(function() {
/* Define a variável que dá swipe no lightbox */
var magnificPopup = $.magnificPopup.instance;
/* Carrega a função quando clica no lightbox (senão não pega a classe utilizada) */
$("a.image-lightbox").click(function(e) {
/* Espera carregar o lightbox */
setTimeout(function() {
/* Swipe para a esquerda - Próximo */
$(".mfp-container").swipe( {
swipeLeft:function(event, direction, distance, duration, fingerCount) {
console.log("swipe right");
magnificPopup.next();
},
/* Swipe para a direita - Anterior */
swipeRight:function(event, direction, distance, duration, fingerCount) {
console.log("swipe left");
magnificPopup.prev();
},
});
}, 500);
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment