Mobile iOS Safari problems and general solutions

Source: Internet
Author: User

The use of overflow in iOS devices will have a lag, solution:-webkit-overflow-scrolling:touch; /* Eliminate stuttering on iOS devices */

The Click event in iOS does not execute: Workaround: ①: Change the target element to <a> or <button>,②: Set the cursor:pointer for the target element; ③:click event written as tounched event

Go: In iOS

When using overflow scroll, the solution to the entire page is dragged when the most extreme situation is reached

Method one, found from the Internet:

functionpreventOverScroll(scrollPane) {// See http://www.quirksmode.org/js/events_order.htmlvarCAPTURE_PHASE = true; // happens first, outside to insidevarBUBBLE_PHASE = false; // happens second, inside to outside// These variables will be captured by the closures belowvarallowScrollUp = true, allowScrollDown = true, lastY = 0;scrollPane.addEventListener(‘touchstart’,function(e) {// See http://www.w3.org/TR/cssom-view/#dom-element-scrolltopallowScrollUp = (this.scrollTop > 0);allowScrollDown = (this.scrollTop < this.scrollHeight – this.clientHeight);// Remember where the touch startedlastY = e.pageY;},CAPTURE_PHASE);// If the touch is on the scroll pane, don’t let it get to the// body object which will cancel itscrollPane.addEventListener(‘touchmove’,function (e) {varup = (event.pageY > lastY);vardown = !up;lastY = event.pageY;// Trying to start past scroller boundsif((up && allowScrollUp) || (down && allowScrollDown)) {// Stop this event from propagating, lest// another object cancel it.e.stopPropagation();} else{// Cancel this eventevent.preventDefault();}},CAPTURE_PHASE);}

Method two thought out, because I found the non-extreme (not the top or bottom) when the entire page will not be dragged, then the problem is simple:

scrollPane.addEventListener(‘touchstart‘, function(){         if(this.scrollTop === 0){             //滚动到1             this.scrollTop =1;         }else if(this.scrollTop == this.scrollHeight - this.clientHeight){             //滚动到最低端-1             this.scrollTop =this.scrollHeight - this.clientHeight -1;         }      }, true);

Mobile iOS Safari problems and general solutions

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.