I have 8 elements on the horizontal scroll that are 500px each and have a margin right of 40px.
The pinned section has a margin-left of 120 and a padding of 80.
The last element on the horizontal scroll is cutted in half , is there a way to fix it?
I fixed it creating a invisible element of 200px (margin + padding) and it worked but it's not a good fix
gsap.registerPlugin(ScrollTrigger)
let container = document.getElementById("container");
let section = document.getElementById("ContainerInformacao");
gsap.to(container, {
x: () => -(section.scrollWidth - document.documentElement.clientWidth),
ease: "none",
scrollTrigger: {
trigger: section,
pin: true,
scrub: 1,
// end: () => "+=" + container.scrollWidth ,
invalidateOnRefresh: true,
end: () => `+=${container.offsetWidth}` // will be updated
}
})