How to disable “swipe” for taphold

送分小仙女□ 提交于 2019-12-11 12:40:45

问题


I have found that the taphold (longclick) function for jquery mobile also seems to cause elements to change the same way by "swiping" as well.

A quick proof of this undesired effect is:

http://api.jquerymobile.com/taphold/

If I "swipe" the box well before 750ms it changes color and it bypasses me having to do a taphold (longclick).

As well as this:

http://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_events_taphold

If I "swipe" the text it also dissapears the same way taphold does.

Threshold changes I tried did not fix this and I would like to know if anyone has a solution to prevent a taphold event on an element from being triggered by "swiping" it as well?

Note: I put "swipe" in quotes because I think it is inherently caused by taphold and not a seperate swipe event. I can't be certain but I have tried tried several things out such as combining swipe and taphold events on a single element with varying thresholds which lead me to think this.


回答1:


In case anyone is interested in an alternative solution. I've discovered a plugin by Rich Adams that has the fix already in place. https://github.com/richadams/jquery-taphold/blob/master/taphold.js

It implements specified boundries for the taphold event. Guess still need to wait for the jquery mobile official to set some boundries to the taphold event of their own but this plugin works just as well and solves the issue for disabling "swipe" on taphold.



来源:https://stackoverflow.com/questions/24542481/how-to-disable-swipe-for-taphold

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!