-1
このJavaScriptイベントをマウスホイールではなくスクロールするように変更しようとしています。私はjavascriptのaddEventListenerを 'wheel'から 'scroll'に変更します。
var scrollVal = e.scrollTop * 0.001;
に
var scrollVal = e.deltaY * 0.001;
を変更しかし、それはまだ動作していない
window.addEventListener('scroll',function (e)
に
window.addEventListener('wheel',function (e)
を変更しようとしたし、この行にしました。これは完全なコードです:
window.addEventListener('wheel',function (e) {
if(!parallaxLocked){
var scrollVal = e.deltaY * 0.001;
introContentDist -= (scrollVal * (window.innerHeight * 0.2));
mainContentDist -= (scrollVal * window.innerHeight);
if(mainContentDist < window.innerHeight){
if(mainContentDist > 0){
var distanceCoveredPercentage = mainContentDist/window.innerHeight;
TweenMax.to(introDiv, 0.1, {y: introContentDist+"px", opacity: 1 * distanceCoveredPercentage});
TweenMax.to(belowFold, 0.1, {y: mainContentDist+"px"});
window.scrollTo(0,0);
if(!firstSlideFadedUp){
if(mainContentDist < window.innerHeight * 0.5){ // if parallaxed up 50%
contentSections[0].className = 'airpoints-module -active'; // fade in first section
}
}
if(!stickyLogosFadedUp){
if(mainContentDist < window.innerHeight * 0.25){ // if parallaxed up 75%
stickyLogo.className = 'c-sticky-logo fade-in'; // fade in sticky logo changer
stickyLogosFadedUp = true;
}
}
} else {
// when scrolled to end, lock divs to final place
TweenMax.to(introDiv, 0.1, {y: "-30%"+"px"});
TweenMax.to(belowFold, 0.1, {y: "0%"});
parallaxLocked = true;
// now that everything is locked in place
setupScrollLogoChanger();
}
}
}
});
$(ウィンドウ).off( 'ホイール')'と '$(ウィンドウ).on( 'スクロール'、機能(E){/ *あなたのコード* /}); ' – Monah