iPhone JavaScript window events
I've been investigating event hook availability in JavaScript on the iPhone. If you want to look at the script I've been using for this, you may find it at:
http://homepage.mac.com/tahoma.toelkes/iPhoneWindowEvents.html
Please be kind with your comments, since I've only been hacking JavaScript off and on over the last 48 hours or so (and I "borrowed" the basis for this script, as the comment at the top of it indicates). ;-)
Anyway, so far, I've been primarily concentrating on the global window events, and I've discovered a few tidbits that other might perhaps find interesting.
1. Starting on the third screen orientation flip, the window object starts getting its onresize event hook called...every time. Why doesn't it happen the first two times? I don't know, but I suspect it's a bug, and I'm going to file it as such soon.
2. Sometimes, when I click a checkbox, I get the following event stream at the window object: onmouseout, onmouseover, onmousedown, onmouseup, onchange, onclick. Other times, I get this simpler stream: onmousedown, onmouseup, onchange, onclick. Also, I've had both sequences without the onchange event (with the expected result that the checkbox state doesn't change. As yet, I've been unable to determine what causes the differences.
3. I have witnessed onmousewheel events while zooming using the pinch gesture; however, again, I've been unable to correlate when it happens to any differences in how I'm manipulating the screen. Grrrr!
Okay, I think it's about time to dive into textarea hooks. I'm going to leave the script I mentioned above static while I'm doing that experimentation. If I do update it later, I'll mention the fact in this blog.
Cheers!
-- Tahoma
http://homepage.mac.com/tahoma.toelkes/iPhoneWindowEvents.html
Please be kind with your comments, since I've only been hacking JavaScript off and on over the last 48 hours or so (and I "borrowed" the basis for this script, as the comment at the top of it indicates). ;-)
Anyway, so far, I've been primarily concentrating on the global window events, and I've discovered a few tidbits that other might perhaps find interesting.
1. Starting on the third screen orientation flip, the window object starts getting its onresize event hook called...every time. Why doesn't it happen the first two times? I don't know, but I suspect it's a bug, and I'm going to file it as such soon.
2. Sometimes, when I click a checkbox, I get the following event stream at the window object: onmouseout, onmouseover, onmousedown, onmouseup, onchange, onclick. Other times, I get this simpler stream: onmousedown, onmouseup, onchange, onclick. Also, I've had both sequences without the onchange event (with the expected result that the checkbox state doesn't change. As yet, I've been unable to determine what causes the differences.
3. I have witnessed onmousewheel events while zooming using the pinch gesture; however, again, I've been unable to correlate when it happens to any differences in how I'm manipulating the screen. Grrrr!
Okay, I think it's about time to dive into textarea hooks. I'm going to leave the script I mentioned above static while I'm doing that experimentation. If I do update it later, I'll mention the fact in this blog.
Cheers!
-- Tahoma
3 Comments:
I was also playing with the event on a div and noticed that the mouseup and mousedown fire only when the finger is removed, not on the initial touch.
After I posted this, I figured out how to make the mousewheel event work predictably. Part of the key is that the iPhone is looking for a two-finger vertical drag (a-la mousewheel control on MacBook laptops) and that this needs to be done inside of a control large enough to register. I accomplished the latter, in part, by using a viewport meta tag. Anyway, check out the example at http://homepage.mac.com/tahoma.toelkes/mousewheel.html
Oh, yeah, I should also mention that another fellow on the iphonewebdev google group beat me to filing the onresize bug by a few hours...
Post a Comment
<< Home