Jump to content
GreenSock

TimTh

offsetY units other than pixels with ScrollTo Plugin?

Go to solution Solved by OSUblake,

Recommended Posts

Hi -

 

When using the ScrollTo plugin I'd like to set the offset using vh instead of px, but offsetY seems to take only numeric values in pixels.  offsetY: "5vh" or even offsetY: "20px" don't seem to work. Am I missing something, or if px is the only unit allowed with ScrollTo, is there a way to accomplish what I'm trying to do with a regular tween, without the ScrollTo plugin?  Apologies if the answer is obvious/basic, I'm new to GSAP and didn't see anything on the forums or with a general google search.  Thanks for any advice!

Link to comment
Share on other sites

  • Solution

Welcome to the forums @TimTh

 

It looks like it only works with numerical values, but if you wanted to do 5vh, it would be the same as 0.05 * innerHeight.

 

  • Like 3
Link to comment
Share on other sites

Awesome, thank you very much!  It's nice to know I wasn't missing something syntactically and even better to have a workaround.  Much appreciated!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×