Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Taphold event fired while scrolling on Blackberry Playbook #1524

Closed
kpozin opened this Issue · 8 comments

7 participants

@kpozin

On the latest version of the Playbook, jQuery Mobile often fires the taphold event while the user is touch-scrolling the screen. There should be some sort of mutex added to prevent this from happening.

Not sure if this is also an issue on other devices.

@toddparker

Just confirming - this is with the latest build (post-4.1)? Can you post a simple JS Bin or JS Fiddle demo page here that I can test on our PlayBook?

@kpozin

Thanks for looking into this, Todd. Here's a simple example: http://jsbin.com/oruhu4/

My proposed solution would be to bind to scroll (i.e. the native event) when a tap event starts. In the scroll handler, calculate scroll speed by comparing time and scroll offset since the last event, and if it's greater than some threshold, call clearTapHandlers(). The threshold would allow us to distinguish intentional scrolling from the jitter that happens when a user tries to hold a finger still to trigger the taphold event.

@toddparker

Thanks for your help, we'll take a look.

@kpozin

Some further notes, now that I've read through most of the relevant code.
handleTouchMove(event) determines whether scrolling occurred based on $.vmouse.moveDistanceThreshold = 10.
On the Playbook, the scroll event gets fired quite often, so even when scrolling quickly, the distance between scroll events is often less than 10 pixels.
As I mentioned above, speed rather than distance should be used in order to accommodate varying scroll event frequencies.

(Sorry about the accidental close!)

@kpozin kpozin closed this
@kpozin kpozin reopened this
@kpozin

In case anyone else has encountered this issue, here's a temporary fix that you can put into your code: https://gist.github.com/1113949

This eliminates most, but not all, unintended tapholds on the Playbook.

You can then check for $.mobile.isScrolling() in your taphold handlers, and not handle the event if the value is true.

@toddparker, it might be possible to adapt this code and incorporate it into jQuery Mobile.

@jblas jblas was assigned
@jasondscott jasondscott referenced this issue from a commit in jasondscott/jquery-mobile
@jasondscott jasondscott Issue #1524 - Taphold event fired while scrolling on Blackberry Playbook
Cause: The vmousecancel event was not being fired for 'this'.

How Fixed: Bound vmousecancel event to document instead of 'this'.

How Tested: Ran the example provided with the issue
(http://jsbin.com/oruhu4/) with this change on BlackBerry Playbook v2.0
and iPad iOS 5.0.1
92cf8d6
@jasondscott jasondscott referenced this issue from a commit in jasondscott/jquery-mobile
@jasondscott jasondscott Issue #1524 - Fixing style - Missing white space a215d4c
@jasondscott

Hey @gseguin Can you close this issue?

@gseguin gseguin closed this
@dpeacock

This behavior still appears to occur on the Playbook with the latest JQuery Mobile (1.1.1 and 1.2.0-rc1).

@viljoviitanen

This is also an issue with jquery mobile 1.3.0, with IE10 on a windows 8 tablet.

My workaround is almost the same that was suggested above, except it's a bit simpler:

var scrolling
$(document).ready(function () {
  $(window).scrollstart(function() {
    scrolling=1
  })
  $(window).scrollstop(function() {
    scrolling=0
  })
}
//then in the taphold callback function
function mycallback() {
  if (scrolling) {
    return
  }
  ....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.