Hi guys,
I've got multiple scroll triggers. One specific scroll trigger (where background gets pinned for the other one to go on top) just starts way before "top top", so it jumps to that section. https://snazzy-torrone-ef6599.netlify.app/
But if you refresh on that section the problem goes.
I've read that it might be because of dynamic content but I'm not adding anything dynamically.
I have a lot of scrolltriggers so I think it might be because of that. My code is nowhere clean.
gsap.registerPlugin(ScrollTrigger);
// parallax effect
const panels = gsap.utils.toArray(".work-wrapper .outer");
panels.forEach((panel, i) => {
gsap.to(panel, {
scrollTrigger: {
trigger: panel,
start: "top top",
pin: i === panels.length - 1 ? false : true,
pinSpacing: i === panels.length - 1 ? true : false,
scrub: 1,
invalidateOnRefresh: true,
},
scale: 1.2
});
gsap.from(panel.querySelector("h3"), {
scrollTrigger: {
trigger: panel,
start: "top top",
pin: i === panels.length - 1 ? false : true,
pinSpacing: i === panels.length - 1 ? true : false,
scrub: 1,
invalidateOnRefresh: true,
},
scale: 0.9,
})
});
const tl = gsap.timeline({ease: "none"});
tl
.to(".display-hero .image-pill", {
scrollTrigger: {
trigger: ".hero-section",
start: "top top",
scrub: 0.5,
invalidateOnRefresh: true,
},
yPercent: -150
})
.to(".floating-image-wrapper img", {
scrollTrigger: {
trigger: ".floating-image-wrapper",
start: "top top",
scrub: 0.5,
invalidateOnRefresh: true,
},
yPercent: -200
});
gsap.utils.toArray(".hero-section .display-hero .text-wrap").forEach((elem, i)=>{
tl.to(elem, {
scrollTrigger: {
trigger: ".hero-section",
start: "top center",
scrub: 0.5,
invalidateOnRefresh: true,
},
xPercent: ()=>i%2 == 0 ? -10 : 10
})
});
tl.to(".hero-description-wrapper", {
scrollTrigger: {
trigger: ".hero-section",
start: "top top",
scrub: 0.5,
invalidateOnRefresh: true,
},
yPercent: -125
})
.to(".big-image-pill-wrapper", {
scrollTrigger: {
trigger: ".hero-section",
start: "top top",
scrub: 0.5,
invalidateOnRefresh: true,
},
yPercent: -80
})
.to(".second-section .bubble-wrap", {
scrollTrigger: {
trigger: ".hero-section",
start: "top top",
scrub: 1,
invalidateOnRefresh: true,
},
yPercent: -10
})
.to(".second-section .bubble-wrap", {
scrollTrigger: {
trigger: ".big-image-pill-wrapper",
start: "center bottom",
end: "bottom top",
scrub: 1,
invalidateOnRefresh: true,
},
y: "-40vw"
});
gsap.utils.toArray(".second-section .second-hero-wrap .display-big").forEach((elem, i)=>{
tl.to(elem, {
scrollTrigger: {
trigger: ".second-section",
start: "top 20%",
end: "bottom center",
scrub: 1,
invalidateOnRefresh: true,
},
xPercent: ()=>i%2 == 0 ? -15 : 15
})
});
gsap.utils.toArray(".fade-in").forEach((elem, i)=>{
gsap.from(elem, {
scrollTrigger: {
trigger: elem,
start: "top 70%",
end: "bottom center",
},
duration: 0.5,
opacity: 0,
y: 50,
})
})
gsap.utils.toArray(".fade-in-right").forEach((elem, i)=>{
gsap.from(elem, {
scrollTrigger: {
trigger: elem,
start: "top center",
end: "bottom center",
},
ease: "power2.out",
duration: 0.5,
opacity: 0,
xPercent: 25,
})
})
gsap.utils.toArray(".fade-in-left").forEach((elem, i)=>{
gsap.from(elem, {
scrollTrigger: {
trigger: elem,
start: "top center",
end: "bottom center",
},
ease: "power2.out",
duration: 0.5,
opacity: 0,
xPercent: -30
})
})
I would like some help please.
Thanks in advance