Jump to content
Search Community

What is the default value for the "scroller" property when using ScrollTrigger?

alexb148 test
Moderator Tag

Recommended Posts

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

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.
×
×
  • Create New...