// 判断鼠标滚动方向 function wheelDirection(fn) { var beforeScrollTop = $(window).scrollTop(); var fn = fn || function(){}; $(window).on('scroll',function(){ var afterScrollTop = $(window).scrollTop(); var direction = afterScrollTop - beforeScrollTop; if( direction === 0 ) return false; fn( direction > 0 ? "down" : "up" ); beforeScrollTop = afterScrollTop; }) }