iPad / jQuery.animate(scroll) issues

老子叫甜甜 提交于 2019-12-30 11:27:07

问题


I have a page that uses jQuery.animate to scroll the body/html of the document, it works fine in browsers but just won't play ball with iPad.

First it is supposed to scroll in the Y direction then X, but on an iPad it scrolls in the Y, then it jumps back to the original position before scrolling in the X direction. After the animations are complete the links that are used to navigate cease to function unless you manually scroll the page, then they will work again!

What am I doing wrong here? The page is found here...

Thanks in advance, Phil.


回答1:


I figured it out. iOS does not scroll the body, but it moves the viewport. This causes some undesired effects when jQuery tries to interact with it. The solution is to scroll a div instead of the body of the document.




回答2:


scrollTop() and scrollLeft() aren't supported on iPad. Try window.pageYOffset and window.pageXOffset.

Not sure what is happening with the nav links freezing until manual scroll - but its not just you - I've seen it before.



来源:https://stackoverflow.com/questions/8359748/ipad-jquery-animatescroll-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!