tags:

views:

1169

answers:

3

I looking for options on how to track user zooming and panning on a page when viewed in Safari on an iPhone. Safari exposes move and gesture events, so theoretically I can keep a running tally of pan and zoom operations, but that seems like overkill since the browser must track that internally.

Is this information exposed through the Document Object Model?

+2  A: 

According to the Safari Web Content Guide, zoom events (double tap) are not exposed, so I'm not sure how you can track this.

I do not believe this information is exposed through the DOM.

Steve Madsen
A: 

I actually think things might have moved on a little since Steve's answer, as having a look at the content guide link he provided I can see a section on Handling Multi-Touch Events and also Handling Gesture Events.

Haven't tried them yet but they look pretty promising. I'll provide an update once I've checked them out and have a demo link available...

Damon Oehlman
google fastflip (http://fastflip.googlelabs.com/) does it, so it's certainly possible
cobbal
+2  A: 

When you zoom in, window.innerWidth is adjusted, but document.documentElement.clientWidth is not, therefore:

var zoom = document.documentElement.clientWidth / window.innerWidth;

(I've tested iOS4, without viewport <meta>).

However, I wouldn't rely on it for anything important. DOM viewport sizes/pixel sizes in mobile browsers are a complete mess.

porneL
Thanks for that. It's a hack, but it sounds like it might actually work, which is at least something.
Jason Kester