在jQuery-mobile中计算滑动距离 [英] Calculate swipe distance in jQuery-mobile

查看:135
本文介绍了在jQuery-mobile中计算滑动距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望您今天过得很好,我正在尝试计算移动网站上的滑动距离(触摸手势),您将如何计算出用户在屏幕上滑动了多少像素?

I hope you are well today, I am trying to calculate the swipe distance (a touch gesture) on a mobile website, how would you work out how many pixels the user has swiped across the screen?

$('.cmButtons').live('swipeleft',function(){
    console.log("swiped left");
});

推荐答案

不确定是否有帮助,但是使用Beta 2,他们已经发布了一些附加的滑动功能

Not sure if this helps but with Beta 2 they have released some additional swipe functionality

添加了可配置的滑动事件阈值

jquery.mobile.event.js滑动代码.对于需要调整的开发人员 这些常数允许更大的垂直位移,并且仍然 注册滑动,此新功能可对其进行调整.谢谢 mlitwin为此做出了贡献.

There were a number of hard-coded constants in the jquery.mobile.event.js swipe code. For developers who need to tweak those constants to allow a greater vertical displacement and still register a swipe, this new feature allows them to be adjusted. Thanks to mlitwin for contributing this.

  • scrollSupressionThreshold(默认值:10像素)–超过此水平 位移,我们将取消滚动
  • durationThreshold(默认值:1000毫秒)–比此时间更长,并且不刷卡
  • horizo​​ntalDistanceThreshold(默认值:30px)–水平滑动 位移必须大于此.
  • verticalDistanceThreshold(默认值:75px)–滑动垂直位移必须小于此值.
  • scrollSupressionThreshold (default: 10px) – More than this horizontal displacement, and we will suppress scrolling
  • durationThreshold (default: 1000ms) – More time than this, and it isn’t a swipe
  • horizontalDistanceThreshold (default: 30px) – Swipe horizontal displacement must be more than this.
  • verticalDistanceThreshold (default: 75px) – Swipe vertical displacement must be less than this.

这篇关于在jQuery-mobile中计算滑动距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆