Home › Forums › Basel support forum › Prevent scroll on image carousel swipe › Reply To: Prevent scroll on image carousel swipe
January 16, 2018 at 9:31 pm
#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!