首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TouchSwipe所有事件

TouchSwipe所有事件
EN

Stack Overflow用户
提问于 2015-04-01 18:30:29
回答 1查看 240关注 0票数 0

我正在尝试处理函数中的事件。所以它在我的gameLogic函数中为每种类型的事件做了一些事情。

不过,水龙头没被认出来。

我该怎么做?我应该将每个事件分开吗?

代码语言:javascript
复制
$(function() {  
    $(".main-wrapper-inner").swipe( {
        //Generic swipe handler for all directions  
        tap:function(event, target) {
            gameLogic("tap");
        },
        swipeLeft:function(event, distance, duration, fingerCount, fingerData) {
          gameLogic("swipeLeft");
        },
        swipeRight:function(event, distance, duration, fingerCount, fingerData) {
          gameLogic("swipeRight");
        },
        swipeUp:function(event, distance, duration, fingerCount, fingerData) {
          gameLogic("swipeUp");
        },
        swipeDown:function(event, distance, duration, fingerCount, fingerData) {
          gameLogic("swipeDown");
        },

        pinchIn:function(event, direction, distance, duration, fingerCount, pinchZoom, fingerData) {
          gameLogic("pinchIn");
        },
        pinchOut:function(event, direction, distance, duration, fingerCount, pinchZoom, fingerData) {
             gameLogic("pinchOut");
        },

       threshold:0,
       fingers: 'all'
    });
});
EN

回答 1

Stack Overflow用户

发布于 2015-06-06 12:48:28

你可以获得滑动方向(但不是挤压方向),所以你可以减少很多代码(见下文)。

关于点击,您不能将threshold: 0设置为在内部禁用所有点击/点击事件。将threshold设置为任何大于0的值,或完全忽略它(默认为75)以使tap功能正常工作

代码语言:javascript
复制
$(function() {  
    $(".main-wrapper-inner").swipe( {
        //Generic swipe handler for all directions  
        tap:function(event, target) {
            gameLogic("tap");
        },
        swipe(event, direction) {
          // You can obtain the swipe direction
          // and process it in your game logic
          gameLogic("swipe", direction);
        }
        pinchIn:function(event) {
          gameLogic("pinchIn");
        },
        pinchOut:function(event) {
          gameLogic("pinchOut");
        },
        threshold: 75, // This must NOT be 0 for taps to work
        fingers: 'all'
    });
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29388469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档