当我开始滚动div竞争时,我想解雇一个或做一些任务。我检查touchend,触摸启动事件它有时会触发,有时候没有。有没有其他方法可以获得滚动事件?
这是我的小提琴 http://jsfiddle.net/ravi1989/s66Ww/3/$(document).on('touchstart', '#realTimeContents', function() {
alert("--")
isScrolling=false;
$('div#realTimeContents').css("height", "")
// $('div#realTimeContents').css("height", null)
});
$(document).on('click', '#realTimeContents', function() {
alert("-Click-")
$('div#realTimeContents').css("height", "")
// $('div#realTimeContents').css("height", null)
});
$(document).on('touchend', '#realTimeContents', function() {
alert("-end-")
isScrolling=false;
$('div#realTimeContents').css("height", "")
// $('div#realTimeContents').css("height", null)
});
答案 0 :(得分:0)
试试这个,
$(document).on('touchstart click touchend', '#realTimeContents', function(e) {
alert(e.type);
$(this).css("height", "")
});
答案 1 :(得分:0)
尝试跟随,我们绑定div滚动事件并得到我们想要的东西:
$(document).scroll(function(){
if(isScrolling()){
alert("scrolling");
}
});
function isScrolling() {
var scrollPosition = $(document).scrollTop();
return (scrollPosition > 100);
}
在这里工作小提琴:http://jsfiddle.net/s66Ww/5/
我希望它有所帮助。