Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
141
rated 0 times [  142] [ 1]  / answers: 1 / hits: 29975  / 8 Years ago, wed, april 13, 2016, 12:00:00

I need code same this for touch devices . help me please



$(window).on('DOMMouseScroll mousewheel', function (e) {
if (ScrollEnable) {
if (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) {
console.log('Down');
} else {
console.log('Up');
}
}
return false;
});


and here is my touch code, But consul just take up i need find down for my website ! what can i do :|



$('body').on({
'touchmove': function(e) {
if (e.originalEvent.touches > 0 || e.originalEvent.touches > 0) {
console.log('Down');
} else {
console.log('Up');
}
}
});

More From » jquery

 Answers
21

You can use scroll event



var lastScrollTop = 0;
$(window).scroll(function(event){
var st = $(this).scrollTop();
if (st > lastScrollTop){
// downscroll code
} else {
// upscroll code
}
lastScrollTop = st;
});

[#62577] Monday, April 11, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
longd

Total Points: 616
Total Questions: 110
Total Answers: 101

Location: Andorra
Member since Sat, May 27, 2023
1 Year ago
;