Created
August 13, 2015 13:27
-
-
Save thiagoeliasr/f5e546407e8db3c8b599 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); |
not working in mobile devices.
Si funciona, quizás debas cambiar variables de CSS o te falte implementar el .js touchSwipe, pero si que funciona.
Good solution, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not working in mobile devices.