最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Detect user's gesture such as swipe - Stack Overflow

programmeradmin4浏览0评论

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 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!

Share Improve this question asked Feb 7, 2011 at 7:17 DayzzaDayzza 1,5577 gold badges18 silver badges30 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

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)

  1. 暂无评论