views:

27

answers:

1

In trying to figure out the scroll position for a UIWebView, I'm attaching a listener in the HTML that will call back to the main app. I attach the javascript listener like:

window.onscroll = function reportScroll() {
    var sY = window.pageYOffset;
    alert('Scroll pos: '+sY);  // Would evetually trigger a URL or something
}

This event only seems to be triggered at the end of a flick scroll on OS 3.2 (iPad), once the deceleration has ended. However this: http://developer.apple.com/safari/library/documentation/appleapplications/reference/safariwebcontent/handlingevents/handlingevents.html#//apple_ref/doc/uid/TP40006511-SW7 seems to indicate that it should be triggered at the end of a single finger pan as well. I really need to know when that pan completes as well. Any help much appreciated, thanks.

+1  A: 

According to QuirksMode Safari iPhone doesn't fire onscroll event on window, but rather on the document (and any other element). I would bet Safari iPad does the same thing.

galambalazs
I tried attaching the function to document.onscroll and it seems to have the same result: triggers the event at the end of deceleration of flick scrolling, but no event after single finger panning. Thanks for the suggestion though.
Matt Hall