I'm working on a calculator for the iPhone. I'm having a problem in
that the button handlers (onclick handlers within an image map) are
getting called after about a 1 second delay. The fastest I can tap
numbers is about 1 per second. Faster than that and Safari recognizes
a double tap instead.
It appears that Mobile Safari is waiting to see if a double tap occurs
before sending the notification. Does anyone know of a way to
disable double tap checking or another handler I could use that has
less of a delay?
- Revar
- Revar
I created an example that illustrates the problem and placed it
<a href="http://www.creativecreek.com/latencytest.html">here</a>.
It is the simplest possible page I could create that illustrates the
problem. The "button" is a styled anchor link with a solid
background color and an onclick handler that just adds one to a
number. The redraw and handler execution time should be minimal in
this case.
On the iPhone, I can tap the test button about 18 times in 10
seconds (1.8 taps/sec) without losing a tap. If I wait until the
number changes before tapping again, then the fastest I've been able
to go is about 15 taps in 10 seconds (1.5 taps/sec).
I'd like to be able to receive notifications at the rate of 4 taps
per second to get my calculator to "feel" responsive.
I"m guessing that the problem is that mobile Safari is wailing until
it is clear that the user has not double tapped before sending the
onclick notification (onmousedown doesn't get delivered any faster).
I would love to have some type of meta tag (with a possible
associated custom notification) that would inform Mobile Safari that
the initial tap should be delivered as soon as possible.
- Clay
iPhone Safari is unfortunately quite selfish with 'touch' events it
shares with the app (as well as with screen, which it gratiuitously
takes over; or with focus, which can be obtained only after a real
tap, i.e. synthesized events don't work). Since the iPhone screen is a
multi-touch surface, the 'touch state' contains 320x480 = 153,600 bits
= 18.75 K of info at any moment. Any change in the touched subset of
points could be passed to the app in real time (encoded in a run-
length form).
Still, for any quick tap you can get the onscroll events right away
(no delay and no change in position or scale), but you don't get the
tap location. You can then at least generate a suitable visual effect
(sound would be even better, but that's inaccessible, too) to let user
know the tap was registered, then wait 500-600 ms for the location
info from the onclick() handler to perform a more specific response.