From 9724b0a214aa5d5eca16ada0c57355cf06631e59 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 18 Jun 2008 09:33:55 +0000 Subject: [PATCH] "Draw bug in OpenLayers.Handler.Box with firefox". Now always set style.left and style.top, so lost events won't result in an incorrect box any more. r=me (closes #1579) git-svn-id: http://svn.openlayers.org/trunk/openlayers@7375 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Handler/Box.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/OpenLayers/Handler/Box.js b/lib/OpenLayers/Handler/Box.js index 0f45a01b79..e0b93b25da 100644 --- a/lib/OpenLayers/Handler/Box.js +++ b/lib/OpenLayers/Handler/Box.js @@ -84,16 +84,14 @@ OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, { * Method: moveBox */ moveBox: function (xy) { - var deltaX = Math.abs(this.dragHandler.start.x - xy.x); - var deltaY = Math.abs(this.dragHandler.start.y - xy.y); + var startX = this.dragHandler.start.x; + var startY = this.dragHandler.start.y; + var deltaX = Math.abs(startX - xy.x); + var deltaY = Math.abs(startY - xy.y); this.zoomBox.style.width = Math.max(1, deltaX) + "px"; this.zoomBox.style.height = Math.max(1, deltaY) + "px"; - if (xy.x < this.dragHandler.start.x) { - this.zoomBox.style.left = xy.x+"px"; - } - if (xy.y < this.dragHandler.start.y) { - this.zoomBox.style.top = xy.y+"px"; - } + this.zoomBox.style.left = xy.x < startX ? xy.x+"px" : startX+"px"; + this.zoomBox.style.top = xy.y < startY ? xy.y+"px" : startY+"px"; }, /**