I'm having an issue in gsap vertical and horizontal screen, it not stop on full page when i scroll
我在GSAP垂直和水平屏幕上遇到问题,当我滚动时它不会在整页上停止
let sections = gsap.utils.toArray(".section")
sections.forEach((section, i) => {
if ( section.classList.contains('horizontal') ) {
const cardsWrap = section.querySelector('.section__cards')
const oneCard = section.querySelector('.section__card')
gsap.to(cardsWrap, {
x: () => { return -( (cardsWrap.scrollWidth - window.innerWidth + window.innerWidth*0.01) + (window.innerWidth/1 - oneCard.offsetWidth/1) ) },
ease: "none",
scrollTrigger: {
trigger: section,
start:() => "center center",
end: () => "+=" + cardsWrap.scrollWidth,
scrub: 1,
pin:true,
snap: 1 / (sections.length - 1),
pin: i === sections.length -1 ? false : true,
invalidateOnRefresh: true,
anticipatePin: 1,
},
});
} else {
ScrollTrigger.create({
markers: false,
trigger: section,
start: () => "top top",
pin:true,
pin: i === sections.length -1 ? false : true,
anticipatePin: 1,
});
}
});
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!