2014-10-09 2 views
0

안녕하세요, 마우스 휠 이벤트를 마지막으로 스크롤 한 곳을 확인하지 않고 위아래로 확인하는 방법이 있는지 확인하는 방법이 있습니다. 스크롤을 사용 중지하고 스크롤 대신 애니메이션을 사용했습니다.scrollTop을 사용하지 않고 위 또는 아래로 스크롤을 확인하는 방법은 무엇입니까?

var currentTop = 0;  
var scrolling = false; 
var allowNextAnimation = true; 

$('.contactDiv').on('scroll touchmove mousewheel', function(e){ 
if (!scrolling && allowNextAnimation) { 

    if (scrollTop) 
     currentTop = currentTop + 70; 
    else if (scrollDown) 
     currentTop = currentTop - 70; 
    scrolling = true; 
    $('.contactDiv').animate({ 
     scrollTop: currentTop 
    }, 500, function(){ 
     scrolling = false; 
     allowNextAnimation = false; 
    }); 

    return false; 
} 
allowNextAnimation = true; 
}); 

scrollTop의 위치를 ​​모른 채 마우스를 위아래로 스크롤 할 수 있는지 알기 위해서는 어떤 방법이 필요합니다. 어떤 충고? 마우스 휠 이벤트를

+0

추적이 답변 확인 : http://stackoverflow.com/questions/18880159/use-jquery-to-check-mousewheel-event-without-scrollbar합니다. 스 와이프 이벤트의 경우 http://hammerjs.github.io/를 사용하시기 바랍니다. 관심이 있으시면 답변으로 설명해 드릴 수 있습니다. – drinchev

답변

0

:

$('html, body').on('mousewheel MozMousePixelScroll', function (event) { 
    var delta = event.originalEvent.wheelDelta * -1 
        || event.originalEvent.detail; 
    if(delta < 0){ 
     console.log('scroll up'); 
    } else { 
     console.log('scroll down'); 
    } 
}); 

당신은 300 ms 동안 차단 마우스 휠 스크롤이 중간 컨테이너가 위/아래에 도달하면 당신은/아래로 마우스 휠을 스크롤을 계속하는 것이 jsFiddle에 example을 볼 수 있습니다. 300ms 동안 사용하지 않으면 문서를 스크롤 할 수 있습니다.

는 터치 이벤트의 경우, mousewhell를 들어 페이지 Y 이벤트 속성

관련 문제