Detect user's gesture such as swipe

浪子不回头ぞ 提交于 2019-12-04 18:48:43

问题


I am using phonegap for build android apps.

I would like to detect user's gesture such as a user's swipe. Is there an event i can call from javascript?

Thanks!


回答1:


I use a JavaScript framework called xui (homepage) that has a similar API to jQuery.

You can use this framework coupled with the swipe plugin to get access to easy gesture events. See the swipe/ directory under that repository for the code and example (specifically under index.html). A brief example:

x$('body').swipe(function(e, data) {
    console.log('type:' + data.type + ' deltaX:' + data.deltaX + ' deltaY:' + data.deltaY + ' distance:' + data.distance + ' delay:' + data.delay+' direction:' + data.direction  );
});



回答2:


jQuery Mobile also provides basic support for gestures (at least tap, long tap and swipe left&right).

Some additional plugins can be found on the Resources site. Maybe there are more of them on the plugin site.



来源:https://stackoverflow.com/questions/4918881/detect-users-gesture-such-as-swipe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!