我认为您应该添加一个索引来标识用户当前所在的部分。
例如,像这样的:
var caseIndex = 0;
const numOfSections = 3;
function handleMouseWheelDirection( direction )
{
if(caseIndex < numOfSections) {
caseIndex++;
}else{
caseIndex=0
}
if ( direction == 'down' ) {
goNextSlide(caseIndex);
} else if ( direction == 'up' ) {
goPrevSlide();
} else {
// this means the direction of the mouse wheel could not be determined
}
}
然后,当您滑到下一个滚动条时-由其索引标识:
const goNextSlide = (slideIndex) =>{
TweenMax.to(sectionMain, 2, {x:0, y:-100*slideIndex} );
TweenMax.to(eval('slide'+slideIndex), 0, {delay:0.4, x:0, y:0, ease: Power4.easeOut, display:"block" } );
}
在我的例子中”
section_main
“更改为”
case_0
所以这是下一个幻灯片的基本工作,你得到了这个想法,所以试着对上一个做同样的工作。