Jump to content
Search Community

Force scrollTrigger to activate when reaching end of page

Mamboleoo test
Moderator Tag

Recommended Posts

Ola!

I'm working on some basic fade-in effect with scrollTrigger and I'm encountering an issue with the last component not being displayed when reaching the end of the page.

As  you can see from the markers, this is not an issue with the plugin, the start position of the last section is never reaching the scroll-start.

 

To avoid this issue I've added a listener on the scroll and when reaching the end of the page, I'm forcing all the tweens to be played.

Would there be a better alternative to this? 

I was looking for a method from ScrollTrigger to activate it manually (e.g. tween.scrollTrigger.force()) because now the tween is being played (in my Codepen) but scrollTrigger is not cleared out.

 

Happy holidays 🎄

Mamboleoo

See the Pen ZEpaxoN by Mamboleoo (@Mamboleoo) on CodePen

Link to comment
Share on other sites

The issue is that I'm not sure only the last section will have the issue.

If you set the last section height to 100px, now the last two sections are never fading-in 😕

See the Pen LYROwWL by Mamboleoo (@Mamboleoo) on CodePen

 

Also I may have images in one of those sections, so the height can be wrong on page load.

I guess this would work (if I had event listener to loaded images)

ScrollTrigger.create({
  trigger: "body",
  start: "bottom bottom",
  onEnter: triggerAllLeftTweens
});

 

Link to comment
Share on other sites

Hey @Mamboleoo

 

It may be a logical aspect.
When the 4th section fades in, its bottom is at 80% of the window height (startTrigger 50% + 30vh).
Logically the window height may only be max 500px so that the 5th section with only 100px height can still be scrolled.
Scrolling needs space.

 

See the Pen 427889ba98b5d67f8449adb2ff4df2ba by mikeK (@mikeK) on CodePen

 

Happy tweening ...

Mikel

  • Like 2
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...