diff --git a/lib/OpenLayers/Events.js b/lib/OpenLayers/Events.js index 4b0dda5b5d..4a9f703038 100644 --- a/lib/OpenLayers/Events.js +++ b/lib/OpenLayers/Events.js @@ -854,7 +854,18 @@ OpenLayers.Events = OpenLayers.Class({ clearMouseCache: function() { this.element.scrolls = null; this.element.lefttop = null; - this.element.offsets = null; + // OpenLayers.Util.pagePosition needs to use + // element.getBoundingClientRect to correctly calculate the offsets + // for the iPhone, but once the page is scrolled, getBoundingClientRect + // returns incorrect offsets. So our best bet is to not invalidate the + // offsets once we have them, and hope that the page was not scrolled + // when we did the initial calculation. + if (!((document.body.scrollTop != 0 || + document.body.scrollLeft != 0) && + navigator.userAgent.match(/iPhone/i))) { + OpenLayers.Console.log("clear"); + this.element.offsets = null; + } }, /**