capturing double-tap in safari mobile

14 views
Skip to first unread message

Jon Brisbin

unread,
May 21, 2008, 11:30:48 AM5/21/08
to iphone...@googlegroups.com
I don't know if this is documented anywhere, but I'm working on an app
where I'd like to capture the double-tap at max zoom to re-center the
page using window.scrollTo. While there isn't a double-tap event, I'm
able to figure out that a double-tap has happened because the onscroll
event fires whenever the screen is tapped, whether the user actually
scrolls the page or not. Checking the time between the two firings of
the onscroll event will tell me if the user has double-tapped within
the timeout period I set. Something like:

var inDoubleTap = false;
var doubleTapTimer = false;
window.onscroll = function(){
if(!doubleTapTimer){
doubleTapTimer = setTimeout(function(){ inDoubleTap = false; },
500);
}
if(!inDoubleTap){
inDoubleTap = true;
}else{
// call function to run if double-tap
myFunction();
inDoubleTap = false;
}
}

I can add a check to the orientation as well to limit this double-tap
capture to landscape mode.


Thanks!

Jon Brisibn
http://jbrisbin.com

Matt Sephton

unread,
May 22, 2008, 5:20:02 AM5/22/08
to iphone...@googlegroups.com
Nice work

Jon Brisbin

unread,
May 22, 2008, 12:29:52 PM5/22/08
to iphone...@googlegroups.com
I'm working on a jQuery plugin that encapsulates this intelligently.
I'm new to jQuery plugins, though, so it's a bit of a trial-and-error
type thing...

Thanks!

Jon Brisibn
http://jbrisbin.com

wayne

unread,
Jul 12, 2008, 11:13:39 PM7/12/08
to iPhoneWebDev
The method doesn't work on iPhone Version 2.0. To fix it, on each
scroll event check screen position and size and if neither changed
since the last scroll event, then interpret the new scroll event as a
double tap.

James Churchman

unread,
Jul 22, 2008, 5:40:57 PM7/22/08
to iphone...@googlegroups.com
hi guys

The code above looks great, but is there any way to know what the object under the users finger was actually clicked -- obviously i want to have an on double click like event on many of the buttons in my site (well, in fact the uiwebview inside an iphone app)


many thanks

james

2008/7/13 wayne <night...@omegapoint.com>:
Reply all
Reply to author
Forward
0 new messages