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