开发者

Detect user's gesture such as swipe

开发者 https://www.devze.com 2023-02-08 18:37 出处:网络
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 callfrom javascript?

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!


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  );
});


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号