如何使用 iScroll 同时滚动 2 个 div
我有 2 个 div 都使用 iScroll。现在我希望两个 div 在其中一个 div 滚动时也滚动。
我希望它们同时滚动
这可能吗?
I have 2 divs that both uses iScroll. Now I would like both divs to scroll when one of them are scrolled.
I want them to scroll simultaneously
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
scrollTo
方法在滚动任何 div 时将第二个 div 滚动到指定位置。它需要三个参数,其中超时是可选的。scrollTo(x, y, timeout)
- 滚动到滚动区域内的任何 x,y 位置。You can use
scrollTo
method to scroll the second div at a specified position on scrolling any div. It takes three arugments out of which timeout is optional.scrollTo(x, y, timeout)
- scrolls to any x,y location inside the scrolling area.尝试按如下方式构造
div
:然后为
#wrapper
定义 iscroll,然后您就可以同时滚动两个 div。这是最简单的方法。或者您可以尝试获取
onScroll 事件
。虽然在滚动过程中不可能准确地到达滚动位置,但您仍然可以在onScrollMove
和onScrollEnd
上获得 is in。希望这对您有帮助。Try structuring the
div
as follows :Then define iscroll for
#wrapper
and you get to scroll both the div simultaneously. This is the easy way.Or you can try to get the
onScroll event
. Though it is not possible to exactly get on scroll position during scroll but you can still get is in ononScrollMove
andonScrollEnd
. Hope this helps you.