-
-
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/)
This file contains 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