Hello everyone.
What i'm trying to achieve is to have a smooth scroll effect applied to a .main div that wraps the whole page.
The effect i reached is great but in the moment in which i add triggers inside, the position of them is wrong and seems affected by the smooth effect in a wrong way.
This is the code for the page smoothing part:
gsap.to(".container", {
yPercent: -100,
y: "100vh",
scrollTrigger: {
scrub: 1,
trigger: ".container",
start: "top top",
end: document.querySelector(".container").clientHeight,
markers: true
}
})
I set the yPercent as the -100% of the page and had to add also a y property to "100vh" in order to remove from the calculation the px height of the viewport that was in excess.
The .container is a relative positioned element that wraps everything and is wrapper by a .main div that is positioned in fixed and with overflow hidden.
This parts gives no problems.
But, when i insert a simple trigger (which is in this case a relative positioned tag p inside the page), it places the trigger way down and while i scroll it moves too smoothly up or down.
If the smooth code is removed, the trigger works perfectly, i have problems only when i match the trigger and the smooth.
This is the code of the trigger
gsap.to(".bg", {
duration: 0.5,
autoAlpha: 0,
scrollTrigger: {
toggleActions: "play complete none reverse",
trigger: ".trigger",
start: "top top",
markers: {startColor: "pink", endColor: "pink", fontSize: "12px"}
}
})
Thank you in advance for the help.