Share Posted July 9, 2020 Hello, im trying to use a function to return a dynamic number value for the position of 'scroller-start' of my scroll trigger // simplified scroll trigger here ScrollTrigger.create({ trigger: ".logo", start: "top DYNAMIC-VALUE-HERE", end: "+=500", scrub: 1, }); // function to return dynamic value function get_start() { return document.querySelector('.fixed-elements h2').offsetTop } I see that its possible to use functions in the start option, but how do use it only for the 2nd value as shown above? Link to comment Share on other sites More sharing options...
Share Posted July 9, 2020 create a variable which is placed out site of the string. start: "top " + DYNAMIC-VALUE-HERE, Something like this should work. 1 Link to comment Share on other sites More sharing options...
Share Posted July 9, 2020 Hey mfk and welcome to the GreenSock forums. 2 hours ago, mfk said: I see that its possible to use functions in the start option, but how do use it only for the 2nd value as shown above? As mvaneijgen said, you can concatenate the value with a string. Using your function it should look something like this: start: "top " + get_start(), 2 Link to comment Share on other sites More sharing options...
Author Share Posted July 10, 2020 thanks! that sorted it out Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now