0

I wrote this code that executes a function everytime the user reaches the bottom of the page. As some elements are appended, the page height changes, and looks like after the first time, its triged, the trigger is not updated to the bottom of the page, and I have to go up again to trigger it.

How can I tell gsap to update the triger position, like a refresh?

gsap.to(".hidden-posts-trigger", {
  y: '+=50',
  scrollTrigger: {
    trigger: "body",
    start: "bottom bottom",
    end: "top 100px",
    scrub: true,
    markers: true,
    id: "scrub",
    onEnter: function() {
      console.log("Entered the scroll trigger area.");
      // boxWrap.addClass("hidden");
      for (var i = 0; i < 5; i++) {

        callData(count); // Once at the bottom of the page -> call 5 times

        console.log(count);
        count++;
        
      }
    },
    onLeaveBack: function() {
      console.log("Left the scroll trigger area.");
    }
  }
});
Fernando Souza
  • 1,748
  • 1
  • 20
  • 36

0 Answers0