Jump to content
Search Community

ScrollTrigger on whole page doesn't work without markers

Men At Code test
Moderator Tag

Recommended Posts

Hello,

I've applied ScrollTrigger to the whole page, in order to achieve a smooth effect. 

When I remove markers or set them to false, the page stays fixed on first viewport and doesn't scroll; while with markers active (true) it works perfectly. 

I was wondering if there's some setting that i'm missing or some problems in the configuration. 

This is how i initialized it:

 

gsap.to('.container', {
      y: () => -(this.scrollService.height - document.documentElement.clientHeight),
      ease: "none",
      scrollTrigger: {
        id: "scrollTrigger",
        start: "top top",
        end: document.querySelector(".container").clientHeight,
        scrub: 1,
        invalidateOnRefresh: true,
        refreshPriority: 1,
        markers: true
      }
    });

as soon as i set markers false, it breaks. 

If anyone knows what's wrong, it'd be great, cause i've done some research but can't figure out why markers need to be active.

Thank you very much

Link to comment
Share on other sites

It definitely sounds like the problem is that you've got your page set up WITHOUT ANY SCROLL. ScrollTrigger doesn't add extra scroll or anything for you (well, unless you do pinning). I imagine you just need to tweak your CSS so that your page is set up to have some scroll. Adding markers obviously would place them down below the viewport, thus making it scrollable. That's probably why it's working only when you have markers: true. Sounds like some simple issues with your CSS/setup. Like maybe something like body { height: 200vh; }

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