HTML5 the upper and lower left and right sliding problem of mobile end

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.