【问题标题】:How to detect rubber band event for scrollable div on iPhone web view?如何在 iPhone 网页视图上检测可滚动 div 的橡皮筋事件?
【发布时间】:2013-11-05 03:43:05
【问题描述】:
我为 iPhone 制作了一个网页,其中有一个顶部和一个底部固定 div。在它们之间,有一个可滚动的 div。我正在使用'-webkit-overflow-scrolling: touch;'启用快速滚动。
现在,如果滚动到达中间 div 的顶部或底部,就会出现橡皮筋效果。这是我想要的效果!
但是,我该如何捕捉事件呢?这样我就可以使用 javascript/jquery 在橡皮筋效果上做一些有趣的事情。谢谢!
【问题讨论】:
标签:
javascript
jquery
iphone
css
scroll
【解决方案1】:
啊,就这么简单
scrollable_div.on('touchmove', function () {
if (its_first_element.position().top > top_fixed_div.height()) {
// Rubber band effect happened, assuming the scrollable_div is vertically next to the top_fixed_div
}
});