From 0ee3c64dd860ba26f7d7587b1a5726f7fcaa092f Mon Sep 17 00:00:00 2001 From: Mihai Varga Date: Tue, 29 Sep 2015 13:12:30 +0300 Subject: [PATCH] loleaflet: don't pan horiz/vertic when doc fits viewing area --- loleaflet/src/dom/Draggable.js | 12 ++++++++++++ loleaflet/src/map/handler/Map.Drag.js | 1 + 2 files changed, 13 insertions(+) diff --git a/loleaflet/src/dom/Draggable.js b/loleaflet/src/dom/Draggable.js index 22630743c..3df1342c6 100644 --- a/loleaflet/src/dom/Draggable.js +++ b/loleaflet/src/dom/Draggable.js @@ -83,6 +83,18 @@ L.Draggable = L.Evented.extend({ newPoint = new L.Point(first.clientX, first.clientY), offset = newPoint.subtract(this._startPoint); + if (this._map) { + if (this._map.getDocSize().x < this._map.getSize().x) { + // don't pan horizontaly when the document fits in the viewing + // area horizontally (docWidth < viewAreaWidth) + offset.x = 0; + } + if (this._map.getDocSize().y < this._map.getSize().y) { + // don't pan vertically when the document fits in the viewing + // area horizontally (docHeight < viewAreaHeight) + offset.y = 0; + } + } if (!offset.x && !offset.y) { return; } if (L.Browser.touch && Math.abs(offset.x) + Math.abs(offset.y) < 3) { return; } diff --git a/loleaflet/src/map/handler/Map.Drag.js b/loleaflet/src/map/handler/Map.Drag.js index 62ec3323c..10b3b4aca 100644 --- a/loleaflet/src/map/handler/Map.Drag.js +++ b/loleaflet/src/map/handler/Map.Drag.js @@ -20,6 +20,7 @@ L.Map.Drag = L.Handler.extend({ var map = this._map; this._draggable = new L.Draggable(map._mapPane, map._container); + this._draggable._map = map; this._draggable.on({ down: this._onDown,