3 回答

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超4個(gè)贊
scrollTop
scrollTop
var lastScrollTop = 0;$(window).scroll(function(event){ var st = $(this).scrollTop(); if (st > lastScrollTop){ // downscroll code } else { // upscroll code } lastScrollTop = st;});

TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊
$(window).bind('mousewheel', function(event) { if (event.originalEvent.wheelDelta >= 0) { console.log('Scroll up'); } else { console.log('Scroll down'); }});
$(element).scroll
mousewheel
originalEvent
wheelDelta
mousewheel
event.preventDefault()

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊
(function () { var previousScroll = 0; $(window).scroll(function(){ var currentScroll = $(this).scrollTop(); if (currentScroll > previousScroll){ alert('down'); } else { alert('up'); } previousScroll = currentScroll; });}()); //run this anonymous function immediately
添加回答
舉報(bào)