在jQuery-mobile中计算滑动距离

前端之家收集整理的这篇文章主要介绍了在jQuery-mobile中计算滑动距离前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我希望你今天很好,我正在尝试计算移动网站上的滑动距离(触摸手势),你将如何计算出用户在屏幕上滑动了多少像素?
$('.cmButtons').live('swipeleft',function(){
    console.log("swiped left");
});

解决方法

不确定这是否有帮助,但是对于Beta 2,他们已经发布了一些额外的滑动功能

> http://jquerymobile.com/blog/2011/08/03/jquery-mobile-beta-2-released/

Configurable swipe event thresholds added

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 (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.
原文链接:https://www.f2er.com/jquery/178585.html

猜你在找的jQuery相关文章