loleaflet: don't pan horiz/vertic when doc fits viewing area

This commit is contained in:
Mihai Varga 2015-09-29 13:12:30 +03:00
parent 8b3b16d6e1
commit 0ee3c64dd8
2 changed files with 13 additions and 0 deletions

View file

@ -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; }

View file

@ -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,