问题
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?
回答1:
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.
回答2:
Try structuring the div
as follows :
<div id=wrapper>
<div id="scroller">
<div id="div1">
<div id="child1"></div>
</div>
<div id="div2">
<div id="child2"></div>
</div>
</div>
</div>
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 on onScrollMove
and onScrollEnd
. Hope this helps you.
来源:https://stackoverflow.com/questions/8806811/how-to-scroll-2-divs-at-the-same-time-with-iscroll