From 5925cb12d724383588cc68288d71ee94dbcc2faf Mon Sep 17 00:00:00 2001 From: tschaub Date: Thu, 29 Sep 2011 19:46:00 -0600 Subject: [PATCH] Only shift extents that cross once. --- lib/OpenLayers/BaseTypes/Bounds.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/OpenLayers/BaseTypes/Bounds.js b/lib/OpenLayers/BaseTypes/Bounds.js index 83e0c79ded..25e4a9cbde 100644 --- a/lib/OpenLayers/BaseTypes/Bounds.js +++ b/lib/OpenLayers/BaseTypes/Bounds.js @@ -652,21 +652,24 @@ OpenLayers.Bounds = OpenLayers.Class({ if (maxExtent) { var width = maxExtent.getWidth(); + var newRight = newBounds.right - rightTolerance; + var newLeft = newBounds.left + leftTolerance; + //shift right? while (newBounds.left < maxExtent.left && - newBounds.right - rightTolerance <= maxExtent.left ) { + newRight <= maxExtent.left ) { newBounds = newBounds.add(width, 0); } //shift left? - while (newBounds.left + leftTolerance >= maxExtent.right && + while (newLeft >= maxExtent.right && newBounds.right > maxExtent.right ) { newBounds = newBounds.add(-width, 0); } - // crosses right? force left - if (newBounds.left + leftTolerance < maxExtent.right && - newBounds.right - rightTolerance > maxExtent.right) { + // crosses right only? force left + if (newLeft < maxExtent.right && newLeft > maxExtent.left && + newRight > maxExtent.right) { newBounds = newBounds.add(-width, 0); } }