I am trying to swap over from ScrollMagic to your lovely ScrollTrigger plugin, but I ran into an issue pretty quickly. I have very little JavaScript experience, but I am trying to learn! So forgive me if I have made obvious mistakes.
I want to have a simple pinned header so I can trigger some animations inside of it on scroll, I just want it pinned for a little bit then it moves to reveal the page content.
I had this working in ScrollMagic, and I am close here, but I get this janky bouncing around when it moves past/or back up to the trigger.
Check it out here: Staging Site
I tried searching around a bit, and tried a few things with no luck.
Here is my JS:
let st = ScrollTrigger.create({
trigger: ".trigger",
pin: true,
start: "top top",
end: "+=500",
anticipatePin: 1,
scrub: 1, // smooth scrubbing, takes 1 second to "catch up" to the scrollbar
})
console.log(st.pin); // pin element (not selector text)
I basically pulled it from the documentation for pinning and messed around with it a bit. It doesn't seem like any of my changes helped though.
Thanks for the help and I really appreciate any advice!