javascript 如何在 jQuery 中向上和向下滑动?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19873368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to swipe up and swipe down in jQuery?
提问by user2648752
Can you please tell me how how to swipe up and swipe down in jQuery + jQuery mobile.
你能告诉我如何在 jQuery + jQuery mobile 中向上和向下滑动。
I already use this plugin: How to swipe top down JQuery mobile
我已经在使用这个插件: 如何从上往下滑动 JQuery mobile
Demerit: When I scroll the contents it calls swipe up and down function. Can you please give best solution so that I will able to scroll my content and swipe up and down using jQuery or jQuery mobile.
缺点:当我滚动内容时,它会调用上下滑动功能。您能否提供最佳解决方案,以便我能够滚动我的内容并使用 jQuery 或 jQuery mobile 上下滑动。
回答by Ved
Download from https://github.com/mattbryson/TouchSwipe-Jquery-Plugin
从https://github.com/mattbryson/TouchSwipe-Jquery-Plugin下载
Add in your html page
在你的html页面中添加
<script src="js/jquery.touchSwipe.min.js"></script>
$("#id").swipe( {
swipeUp:function(event, direction, distance, duration) {
//console.log("You swiped " + direction)
},
swipeDown:function(event, direction, distance, duration) {
//console.log("You swiped " + direction)
},
click:function(event, target) {
},
threshold:100,
allowPageScroll:"vertical"
});
OR try this one https://github.com/watusi/jquery-mobile-iscrollview