Forked from thiagoeliasr/swiper-magnific-popup.js
Created
September 27, 2018 12:01
-
-
Save timonweb/640417541234cb7464da6c8987388735 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/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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