-webkit-overflow-scrolling将对象插入DOM中的问题

时间:2012-07-21 21:39:46

标签: ios mobile-safari

我正在使用-webkit-overflow-scrolling:触摸iPad上的原生滚动功能。但我遇到了一个很奇怪的问题:

我有一个div有各种各样的孩子。如果这些孩子足够大,可以创建滚动的需要,设备可以正确地滚动,动力和所有。但是,如果这个div不够大,不需要滚动,并且突然插入元素并且现在需要滚动,则根本无法滚动元素。

我希望这不会令人难以置信地混淆,但如果有人能说明在这种情况下该怎么做,那就太棒了。关于这个属性的文档不多。

编辑:尝试过这么多测试,现在看来它只是一个普遍断断续续的问题。对于我的整个网络应用程序,无论内容如何,​​每5次左右,滚动就会失败。

1 个答案:

答案 0 :(得分:1)

我有同样的问题,似乎在添加新DOM元素后分配CSS类似乎工作正常:

// your code to add a div to the DOM
// the div contains a scrollable div with the content class
setTimeout(function(){
  // this is using JQuery
  div.find(".content").addClass("overflowScroll");
}, 1);

// CSS class
.overflowScroll {
  overflow: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
}

// The HTML for the div
// I am adding a dynamic list to the content div
// which should use the overflow scroll
<div class="panel">
  <div class="header">

  </div>
  <div class="content"></div>
</div>