Reputation: 22926
I'm trying to get javascript to scroll the page to a target position, something like:
scrollbarxpos += (targetscrollbarxpos - scrollbarxpos) / 100.0f;
And basically keep calling that line of code until scrollbarxpos = targetscrollbarxpos.
Any idea how I can go about doing this?
Upvotes: 0
Views: 4229
Reputation: 15370
Have you looked at the scrollTo function? It allows you to scroll to a position on a page with x- or y- coordinates. If you want to animate the scroll, you could use some combination of setInterval
and clearInterval
to call scrollTo
until you've reached your desire y-position.
Upvotes: 2