201508061129_ Mobile development-prevent touch movement resulting in the entire interface "threadbare"

Source: Internet
Author: User

//prevents scrolling of the entire page after the content area rolls overvarContent = Document.queryselector (' main ');varStarty;content.addeventlistener (' Touchstart ',function(e) {starty= E.touches[0].clienty;}); Content.addeventlistener (' Touchmove ',function(e) {//High level means scrolling up    //bottom position indicates scroll down    //1 allowable 0 Forbidden    varStatus = ' 11 '; varEle = This; varCurrentY = E.touches[0].clienty; if(Ele.scrolltop = = 0) {        //disable scrolling up and down if content is smaller than the containerStatus = Ele.offsetheight >= ele.scrollheight? ' 00 ': ' 01 '; } Else if(Ele.scrolltop + ele.offsetheight >=ele.scrollheight) {//It's already rolled to the bottom. Scroll up onlyStatus = ' 10 '; }    if(Status! = ' 11 ') {        //determine the current scrolling direction        varDirection = currenty-starty > 0? ' 10 ': ' 01 '; //operation direction and the current allowable state and operation, the result of the operation is 0, which means that the direction is not allowed to scroll, the default event is suppressed, the scrolling is prevented        if(! (parseint (Status, 2) & parseint (direction, 2)) {stopevent (e); }    }});

201508061129_ Mobile development-prevent touch movement resulting in the entire interface "threadbare"

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.