javascript - How do I disable vertical scrolling in iOS using Hammer.js? -
I am trying to disable vertical scrolling in iOS with Hammer.js (jQuery version) in a horizontal scrolling list . I have tried to:
$ (document) .hmer (). On ('swipe, drag', 'body', function (event) {if (event.direction == hammer .DIRECTION_UP} event.direction == hammer. DIRECTION_DOWN} {event.preventDefault ();}}); But if it does not work, how can I disable the scroll vertically while still horizontally scrolling?
I have it on ("swipe drag", function (event) {event.ggure.}. ( For example, "swipe drag"). PreventDefault (); if (event.type == "swipe") {swipeAction (event);} and {drag action (event);}});
Here
[edit]
My answer was simply to tell you that you were using the wrong incident . ForeventDefault () In fact, you used the wrong syntax to check the direction of the event. You should be able to manage it in such a way that I have not tested it:
$ (document) .hmer ({drag_lock_to_axis: true}). On ("swipe drag", function (event) {if (event.gesture.direction == hammer. DIRECTION_UP} event.gesture.direction == hammer. DIRECTION_DOWN} {event.gesture.preventDefault ();}}); 2 things have changed: event.gesture.direction and event.gesture.preventDefault (); The incident guideline was the way to do it on older versions of the Hummer JS.
Note: If you want to do something with the swipe event, for example: jump horizontally in large amounts while swiping, you can combine my answer.
Comments
Post a Comment