简体   繁体   English

处理jQuery中的向上/向下滑动事件

[英]Handling swipe up/down events in jQuery

I am using jquery.touchSwipe.js in fiddle. 我在小提琴中使用jquery.touchSwipe.js。 I downloaded it from here and inserted jquery.touchSwipe.js in my dropbox .run, but it didn't work for. 我从这里下载了该文件,并将jquery.touchSwipe.js插入了我的保管箱.run中,但没有用。 I want to capture swipe up and down events along with scrolling. 我想捕获上下滚动事件以及滚动。 Here is my fiddle . 这是我的小提琴

$("#test").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"
});

Your path to the TouchSwipe plugin is incorrect. 您的TouchSwipe插件路径不正确。 You are linking to Dropbox's download page rather than the file itself which is here: 您链接到Dropbox的下载页面,而不是文件本身,链接在这里:

https://dl.dropboxusercontent.com/s/asv82fbz1am8e8w/jquery.touchSwipe.js

I've updated your Fiddle: http://jsfiddle.net/YB5sq/1/ 我已经更新了您的小提琴: http : //jsfiddle.net/YB5sq/1/

Update: From our discussion I think you also want to be able to not trigger a swipe event when the user is trying to scroll an element. 更新:从我们的讨论中,我认为您还希望在用户尝试滚动元素时触发滑动事件。 You can do that to - the documentation tells you how. 您可以这样做- 文档告诉您如何操作。 By default anything with a class of noSwipe won't trigger a swipe but you can also specify elements. 默认情况下,任何类型为noSwipe都不会触发滑动,但是您也可以指定元素。 EG: http://jsfiddle.net/YB5sq/5/ EG: http//jsfiddle.net/YB5sq/5/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM