From 09bcb46a038ef240a670b3862ffe1eab61ae5ec3 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 16 Mar 2011 02:52:43 +0000 Subject: [PATCH] fixing scroll position issue on the IPhone by only clearing the mouse cache conditionally. r=erilem (closes #3132) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11706 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Events.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; + } }, /**