How can I determine the direction of a jQuery scroll event?

后端 未结 25 1501
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-21 22:24

I\'m looking for something to this effect:

$(window).scroll(function(event){
   if (/* magic code*/ ){
       // upscroll code
   } else {
      // downscrol         


        
25条回答
  •  醉梦人生
    2020-11-21 23:27

    in the .data() of the element you can store a JSON and test values to launch events

    { top : 1,
       first_top_event: function(){ ...},
       second_top_event: function(){ ...},
       third_top_event: function(){ ...},
       scroll_down_event1: function(){ ...},
       scroll_down_event2: function(){ ...}
    }
    

提交回复
热议问题