Home Forums Basel support forum Prevent scroll on image carousel swipe Reply To: Prevent scroll on image carousel swipe

#33736

floristb
Participant

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!