Skip to content

Instantly share code, notes, and snippets.

@bakura10
Last active October 29, 2021 10:17
Show Gist options
  • Save bakura10/b0647ef412eb7757fa6f0d2c74c1f145 to your computer and use it in GitHub Desktop.
Save bakura10/b0647ef412eb7757fa6f0d2c74c1f145 to your computer and use it in GitHub Desktop.
(function() {
var touchingCarousel = false,
touchStartCoords;
document.body.addEventListener('touchstart', function(e) {
if (e.target.closest('.flickity-slider')) {
touchingCarousel = true;
} else {
touchingCarousel = false;
return;
}
touchStartCoords = {
x: e.touches[0].pageX,
y: e.touches[0].pageY
}
});
document.body.addEventListener('touchmove', function(e) {
if (!(touchingCarousel && e.cancelable)) {
return;
}
var moveVector = {
x: e.touches[0].pageX - touchStartCoords.x,
y: e.touches[0].pageY - touchStartCoords.y
};
if (Math.abs(moveVector.x) > 7)
e.preventDefault()
}, {passive: false});
})();
@vasanthangel4
Copy link

HI @bakura10 : iOS 15 touch scrolll is not working. if you have fix. please help me to resolve the iOS 15 scroll issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment