2016-12-26 9 views
0

私はfullPage.jsを使って1ページのスライドを扱っています。ここで mousewheel.scrollがFirefoxで動作しない

は私のデモです:上下にスクロールしたときに使用して

http://codepen.io/r0ysy0301/pen/rWKxQB

は、私がイベントを作成します。ボタンnextが位置を変更します。

次に、私は変数を作成し続け、activeクラスを確認するフラグです。その場合active、ボタンnextのCSS位置を変更してください。

しかし、Chromeでのみ動作するようですが、Firefoxでテストしても何も起こりません。

私もイベントkeyupでテストしたが、それは完全に動作していたので、イベントmousewheelの問題を考えると思います。

答えて

1

Firefoxは"mousewheel"を認識しません。以下はトレーニングです。

は、リスナーの両方のイベント

$(window).on("mousewheel DOMMouseScroll", function(e){ 
    e.preventDefault(); 
}); 

または別々のFirefoxをアドレスを使用します。

var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel" //FF doesn't recognize mousewheel as of FF3.x 

if (document.attachEvent) //if IE (and Opera depending on user setting) 
    document.attachEvent("on"+mousewheelevt, function(e){alert('Mouse wheel movement detected!')}) 
else if (document.addEventListener) //WC3 browsers 
    document.addEventListener(mousewheelevt, function(e){alert('Mouse wheel movement detected!')}, false) 

Original source

+0

良いが答えました。 。ありがとう@TRiNE – vanloc

関連する問題