How to disable vertical scroll while enable swipeleft and swiperight event using jquery mobile?
-
29-06-2021 - |
Вопрос
I have a html jquery mobile multi-page and using swipeleft and swiperight events to flip pages. it works great.
Now I wanna disable the vertical scroll.
From solution I found in stackoverflow, it suggest to use the following
$(document).delegate('.ui-content', 'touchmove', false);
but in this case, the original swipeleft and swiperight events are disabled too.
Is there a way that I can disable the vertical scroll while keeping the swipeleft and swiperight events?
Решение
You could add the following to your
<script>
function BlockMove(event) {
// Tell Safari not to move the window.
event.preventDefault();
}
</script>
and add this to your body tag
<body onload="setTimeout(function() { window.scrollTo(0, 1) }, 100);" ontouchmove="BlockMove(event);">
This will disable the page scrolling allowing you to swipe
Не связан с StackOverflow