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 post Share on other sites
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 post Share on other sites