On the mobile page, if you want to implement "top carousel, finger touch left and right swipe"
My solution is to stop the default event by listening to the swipe to complete
Div.addeventlistener (' Touchmove ', function (event) { event.preventdefault ();//block browser default event})
So, the left and right sliding can be done, but touch this div, the page can not swipe up and down, how to do?
When Touchmove, change the scrolltop value of window in real time?
Does this have a native sliding effect?
What solutions do we have?
The problem has been solved, the idea is
var Xx,yy,xx,yy,swipex,swipey; Div.addeventlistener (' Touchstart ', function (event) { xx = Event.targettouches[0].screenx; yy = Event.targettouches[0].screeny; Swipex = true; Swipey = true; }) Div.addeventlistener (' Touchmove ', function (event) { XX = Event.targettouches[0].screenx; YY = Event.targettouches[0].screeny; if (Swipex && math.abs (xx-xx)-math.abs (yy-yy) >0) //swipe around { event.stoppropagation ();//Organization Bubbles Event.preventdefault ();//block Browser default Event Swipey = false; Swipe left and right} else if (Swipey && math.abs (xx-xx)-math.abs (yy-yy) <0) { //swipe up/down Swipex = False ; Swipe up and down, using the browser default slide } })
You can determine the direction of the move, and then block the default behavior when the level, and other times do not stop the OK
In fact, simply judge move is the level is not good, if the user is inclined to slide how to judge?
My idea is to implement such a overlay on this carousel
When the user is triggered from a touchstart end or move to B, or b start, ends on C and is judged to be right-slip. Zoli is the opposite.
HTML5 the upper and lower left and right sliding problem of mobile end