Prevent scroll on image carousel swipe
-
Dear support,
Currently when you swipe on mobile on the product pages between images the page still scrolls which gives a bad user experience. Is there a way to prevent scrolling when swiping?
For example see:
https://www.etq-amsterdam.com/shop/low-5-army-sandshell/
Already fixed it with the following code:
var xPos = null;
var yPos = null;
window.addEventListener( “touchmove”, function ( event ) {
var touch = event.originalEvent.touches[ 0 ];
oldX = xPos;
oldY = yPos;
xPos = touch.pageX;
yPos = touch.pageY;
if ( oldX == null && oldY == null ) {
return false;
}
else {
if ( Math.abs( oldX-xPos ) > Math.abs( oldY-yPos ) ) {
event.preventDefault();
return false;
}
}
} );
This would be a nice addition to your theme as it improves the mobile experience in a great way!
Hi,
Could you please specify where exactly did you add this code?
Thank you
Hi,
I have added it within the Custom JS on document ready section. Major improvement on the user experience on all touch devices. My advice is to add this within the default code of the template to let all customers benefit.
Kind regards,
Floris
OK, thank you for the suggestion!
The topic ‘Prevent scroll on image carousel swipe’ is closed to new replies.