简体   繁体   English

在iPad上滚动冻结(javascript)

[英]Scroll freezes on iPad (javascript)

I develop app for iPad on javascript. 我在javascript上为iPad开发应用程序。 I have some div. 我有一些div。 Content in this div should be scrollable. 此div中的内容应该是可滚动的。 I added scroll for div using this class: 我使用这个类添加了div的滚动:

.scrollable {
 -webkit-overflow-scrolling: touch;
 overflow-y: scroll !important;
 -webkit-transform: translate3d(0, 0, 0);
}

This way works in 90% cases, but sometimes I try scroll content and nothing happened. 这种方式适用于90%的情况,但有时我尝试滚动内容,没有任何反应。 I wait about 3 sec and try it again - and scroll works. 我等待大约3秒再试一次 - 滚动工作。 I don't have any workaround javascript code which may lead to such behavior. 我没有任何可能导致此类行为的解决方法javascript代码。

Why this behavior can be? 为什么会出现这种行为?

You mentioned that you were loading content dynamically but your fiddle doesn't have that dynamic content load taking place, so I can't answer with a fork of your fiddle, as I would prefer. 你提到你是在动态加载内容,但你的小提琴没有发生动态内容加载,所以我不能用你的小提琴回答,正如我所希望的那样。

However, I just recently had a very similar problem and found that if, after the content is loaded (timing is critical), I set any of the scrollable elements to use -webkit-transform: translate3d(0,0,0); 但是,我最近遇到了一个非常类似的问题,发现如果加载内容之后 (时间很关键),我设置任何可滚动元素都使用-webkit-transform: translate3d(0,0,0); , it seems to resolve the odd "freezing" behavior. ,它似乎解决了奇怪的“冻结”行为。

(In my instance, my dynamic content was loaded in with jQuery's $.get shorthand, so I used the .then() to run a function which would automatically set the appropriate CSS every time new content was loaded.) (在我的实例中,我的动态内容是用jQuery的$.get简写加载的,所以我使用.then()运行一个函数, 每次加载新内容都会自动设置相应的CSS。)

Let me know if this helps. 如果这有帮助,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM