2011/1/5 Miller Medeiros <[email protected]>:
> I'm trying to block the "touchmove" event on iOS safari but only if the
> gesture movement is inside a specific threshold. [...]
> the problem is that preventDefault() cancels the event and I can't
> re-activate it after that: [...] so even if the movement becomes bigger
> than the threshold after some time the browser still won't scroll
I think `touchmove` behaves like `mousemove`, it is relative to the last `move`
event and not `touchstart`, so what you're experiencing is that `touchmove`
will always be a "small" number within your threshold.
. small change . small chage . small change ....
instead of:
. small change . bigger change . even bigger ... etc
> I confess that I didn't tried to clone the "touchmove" event and trigger it
> (using `initTouchEvent`) yet since I'm skeptical that it will solve the
> problem
And I'm a bit skeptical if people want things to be done when they don't try. :)
> I also considered something like dispatching "touchend" and "touchstart" to
> trick the browser but I also didn't tried..
That's more like it. What you need is a custom event, as a combination of
other events. There are two things you can do:
1. register `touchstart` event handler, save the position and use it
to calculate if
the movement goes beyond the threshold (instead of the delta from the last
`move` event.).
2. similar to (1), the only difference is that you specify a timeout
that is restarting
the delta even if there is no new `touchstart` event
I hope I understand your problem correctly.
- Balázs
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]