Prevents page resiliency rollback in iOS, allowing only div.phone_body chunks to be resilient

Source: Internet
Author: User

Instruction for use: Replace selector only: var selector = '. Phone_body ';

/** * Prevents page resilience rollback in iOS, allowing only div.scroller blocks to be elastic */(function () {var selector = '. Phone_body ';    var u = navigator.useragent;    if (U.indexof (' Android ') >-1 | | u.indexof (' Linux ') >-1) {//Android phone//alert ("Android Phone");        } else if (U.indexof (' IPhone ') >-1) {//Apple phone//alert ("Apple phone");        Window.addeventlistener ("Touchmove", handlepagebounce, false);    Window.addeventlistener ("Touchstart", handlepagebounce, false);    } else if (U.indexof (' Windows phone ') >-1) {//winphone phone//alert ("Winphone phone");    }//if ($.os.ios) {//Window.addeventlistener ("Touchmove", handlepagebounce, false);    Window.addeventlistener ("Touchstart", handlepagebounce, false); } function Handlepagebounce (evt) {if (Evt.type = = = "Touchstart") {This._starttouchy = Evt.touches            [0].screeny;        Return        } var panel = $ (evt.target). closest (selector);        if (panel.length = = = 0) return Evt.preventdefault ();var el = panel.get (0);        var canscroll = el.scrollheight > el.clientheight;        var Hastouchoverflow = $ (EL). Computedstyle ("-webkit-overflow-scrolling") = = = = "Touch";        var Hasoverflow = $ (EL). Computedstyle ("Overflowy")!== "hidden";        var height = parseint ($ (EL). Computedstyle ("height"), 10);            if (canscroll && hastouchoverflow && hasoverflow) {var currY = Evt.touches[0].screeny;            var scrollattop = ((this._starttouchy <= CurrY) && (el.scrolltop = = 0));            var scrollatbottom = ((this._starttouchy >= CurrY) && ((el.scrollheight-el.scrolltop) = = = height));        if (Scrollattop | | scrollatbottom) evt.preventdefault ();        } else {evt.preventdefault (); }    }})();

  

Prevents page resiliency rollback in iOS, allowing only div.phone_body chunks to be resilient

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.