alexb148 Posted October 15, 2020 Share Posted October 15, 2020 When creating a ScrollTrigger, I know that if I don't include the "scroller" property it will use the viewport, but I can alternatively give the id of an overflow scrolling element instead. But if I wanted to make the scroller value conditional, what is the default property I should use to tell it to use the viewport? For example: scrollTrigger: { id: triggerId, scroller: (useOverflow ? '#my-overflow-id' : ''), trigger: '#trigger-1', start: 'top top', end: 'bottom top' } An empty string seems to work, but I don't know if that's by chance - I obviously don't want GSAP to be wasting resources trying to find elements in the DOM that don't exist. Link to comment Share on other sites More sharing options...
ZachSaucier Posted October 15, 2020 Share Posted October 15, 2020 Hey Alex. ScrollTrigger defaults to "the viewport" as you say so an invalid value like an empty string will work just fine (so long as that invalid value doesn't throw a JS error like the variable being undefined). 1 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