You’re encountering a conflict between Locomotive Scroll and GSAP scroll-triggered animations, likely because Locomotive Scroll overrides the default scroll behavior, which disrupts how GSAP interprets scroll events.
window, but instead scrolls a custom container.window scroll position, so it won’t detect scrolling changes made by Locomotive unless configured to do so.
To fix this, you need to sync GSAP’s ScrollTrigger with your Locomotive scroll instance:
data-scroll-container (Locomotive’s scroll wrapper) in scrollerProxy().
Example:
```javascript
gsap.registerPlugin(ScrollTrigger);
const scrollContainer = document.querySelector("[data-scroll-container]");
const locoScroll = new LocomotiveScroll({
el: scrollContainer,
smooth: true
});
ScrollTrigger.scrollerProxy(scrollContainer, {
scrollTop(value) {
return arguments.length
? locoScroll.scrollTo(value, 0, 0)
: locoScroll.scroll.instance.scroll.y;
},
getBoundingClientRect() {
return {top: 0, left: 0, width: window.innerWidth, height: window.innerHeight};
},
pinType: scrollContainer.style.transform ? "transform" : "fixed"
});
locoScroll.on("scroll", ScrollTrigger.update);
ScrollTrigger.addEventListener("refresh", () => locoScroll.update());
ScrollTrigger.refresh();
```
<script> tags in Webflow custom code embeds; instead, place your modified JavaScript into the Before </body> tag section in Webflow’s Page Settings or Site Settings.
After setting up scrollerProxy(), make sure all your ScrollTrigger animations specify the custom scroller:
```javascript
scroller: "[data-scroll-container]"
```
```javascript
gsap.to(".navbar", {
backgroundColor: "#fff",
scrollTrigger: {
trigger: ".trigger-element",
start: "top top",
end: "bottom top",
scrub: true,
scroller: "[data-scroll-container]"
}
});
```
start and end positions since Locomotive Scroll might offset elements differently.
To make your GSAP navbar scroll animations work with Locomotive Scroll in Webflow, use ScrollTrigger’s scrollerProxy() to sync scroll behavior and ensure all ScrollTrigger animations declare the correct custom scroller. This enables accurate scroll detection and restores expected animation behavior.