firefox+jquery mousewheel scroll event bug

前端 未结 4 1539
悲哀的现实
悲哀的现实 2020-12-15 05:04

UPDATE Working fix as suggested by David (see below):

replace

    $(\'.scrollMe\').bind(\"mousewheel DOMMouseScroll\", ...) 
         


        
4条回答
  •  死守一世寂寞
    2020-12-15 05:39

    This answer on this question, has the most browsers compatible solution I have found:

    How to detect scroll direction

     $('#elem').on( 'DOMMouseScroll mousewheel', function ( event ) { 
        if( event.originalEvent.detail > 0 || event.originalEvent.wheelDelta < 0 ) { //alternative options for wheelData: wheelDeltaX & wheelDeltaY
            //scroll down
            console.log('Down');
          } else {
            //scroll up
            console.log('Up');
          }
          //prevent page fom scrolling
          return false;
        });
    

提交回复
热议问题