Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

ScrollToPlugin

Sign in to follow this  

| GreenSock
167930

Allows GSAP to animate the scroll position of the window (like doing window.scrollTo(x, y)) or a <div> DOM element (like doing myDiv.scrollTop = y; myDiv.scrollLeft = x;). To scroll the window to a particular position, use window as the target of the tween like this:

//scroll to 400 pixels down from the top
gsap.to(window, {duration: 2, scrollTo: 400});

//or to scroll to the element with the ID "#someID":
gsap.to(window, {duration: 2, scrollTo:"#someID"});

//or to specify which axis (x or y), use the object syntax:
gsap.to(window, {duration: 2, scrollTo: {y: 400, x: 250}});

Or to tween the content of a div, make sure you've set the overflow:scroll on the div and then do this:

//scroll to 250 pixels down from the top of the content in the div
gsap.to(myDiv, {duration: 2, scrollTo: 250});

Learn more in the ScrollToPlugin documentation.

Get an all-access pass to premium plugins, offers, and more!

Join the Club

When is the last time you worked on something you love? Go animate something cool and then share it with us.

- Team GreenSock
Sign in to follow this  


User Feedback

Recommended Comments

There are no comments to display.



Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×