Samuroid Posted June 7, 2022 Share Posted June 7, 2022 I'm trying to achieve a fixed element when the scroll scrub enters the start position however the element jumps to a fixed position and on scrollEnd it jumps to its end position. What I am looking for it that box element is fixed in its original place whilst the rest of the page scrolls until the end of its container. Here is a video demoing what is happening: https://vimeo.com/717982427 And here is the code Im using: ScrollTrigger.create({ trigger: '.fix-me', start: 'top 300px', end: '=+300px', markers: true, pin: true, pinSpacing: false, scrub: true }) It's pretty standard this code as i've used this video as a reference: Link to comment Share on other sites More sharing options...
GSAP Helper Posted June 7, 2022 Share Posted June 7, 2022 It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer. Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo: See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen If you're using something like React/Next/Nuxt/Gatsby or some other framework, you may find CodeSandbox easier to use. Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. Link to comment Share on other sites More sharing options...
Samuroid Posted June 8, 2022 Author Share Posted June 8, 2022 Thank you for this starter template. So it turns out it works in the codepen ( See the Pen BaYOgeY by Sambo (@Sambo) on CodePen ). I'm not sure exactly why it's not working on my development website.... yet. I'm noticing that gsap scrolltrigger adds some CSS to the element that fixes it in certain positions. Maybe I'm missing an import of an important JS file for the animation. I will go through the codepen JS files and add them to my project. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now