split-panes: respect split position when...
converting to/from container coordinates. Also introduce the corresponding 'IgnoreSplits' versions of changed methods because they are needed for repositioning the map-view which is independent of the splits position. They are also needed for stuff outside the map which need not be aware of the splits. Change-Id: I9044a185e5762fa4c4866590e1b7cf456fb2d1dd Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98352 Tested-by: Jenkins Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
This commit is contained in:
parent
4b2ff56750
commit
d58cf80377
2 changed files with 61 additions and 5 deletions
|
@ -43,8 +43,8 @@ L.Control.Scale = L.Control.extend({
|
|||
y = map.getSize().y / 2;
|
||||
|
||||
var maxMeters = L.CRS.Earth.distance(
|
||||
map.containerPointToLatLng([0, y]),
|
||||
map.containerPointToLatLng([this.options.maxWidth, y]));
|
||||
map.containerPointToLatLngIgnoreSplits([0, y]),
|
||||
map.containerPointToLatLngIgnoreSplits([this.options.maxWidth, y]));
|
||||
|
||||
this._updateScales(maxMeters);
|
||||
},
|
||||
|
|
|
@ -504,10 +504,10 @@ L.Map = L.Evented.extend({
|
|||
setZoomAround: function (latlng, zoom, options) {
|
||||
var scale = this.getZoomScale(zoom),
|
||||
viewHalf = this.getSize().divideBy(2),
|
||||
containerPoint = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng),
|
||||
containerPoint = latlng instanceof L.Point ? latlng : this.latLngToContainerPointIgnoreSplits(latlng),
|
||||
|
||||
centerOffset = containerPoint.subtract(viewHalf).multiplyBy(1 - 1 / scale),
|
||||
newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset));
|
||||
newCenter = this.containerPointToLatLngIgnoreSplits(viewHalf.add(centerOffset));
|
||||
|
||||
return this.setView(newCenter, zoom, {zoom: options});
|
||||
},
|
||||
|
@ -913,10 +913,57 @@ L.Map = L.Evented.extend({
|
|||
},
|
||||
|
||||
containerPointToLayerPoint: function (point) { // (Point)
|
||||
if (!this._splitPanesContext) {
|
||||
return this.containerPointToLayerPointIgnoreSplits(point);
|
||||
}
|
||||
var splitPos = this._splitPanesContext.getSplitPos();
|
||||
var pixelOrigin = this.getPixelOrigin();
|
||||
var mapPanePos = this._getMapPanePos();
|
||||
var result = L.point(point);
|
||||
if (point.x <= splitPos.x) {
|
||||
result.x -= pixelOrigin.x;
|
||||
}
|
||||
else {
|
||||
result.x -= mapPanePos.x;
|
||||
}
|
||||
|
||||
if (point.y <= splitPos.y) {
|
||||
result.y -= pixelOrigin.y;
|
||||
}
|
||||
else {
|
||||
result.y -= mapPanePos.y;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
containerPointToLayerPointIgnoreSplits: function (point) { // (Point)
|
||||
return L.point(point).subtract(this._getMapPanePos());
|
||||
},
|
||||
|
||||
layerPointToContainerPoint: function (point) { // (Point)
|
||||
|
||||
if (!this._splitPanesContext) {
|
||||
return this.layerPointToContainerPointIgnoreSplits(point);
|
||||
}
|
||||
|
||||
var splitPos = this._splitPanesContext.getSplitPos();
|
||||
var pixelOrigin = this.getPixelOrigin();
|
||||
var mapPanePos = this._getMapPanePos();
|
||||
var result = L.point(point)._add(pixelOrigin);
|
||||
|
||||
if (result.x > splitPos.x) {
|
||||
result.x -= (pixelOrigin.x - mapPanePos.x);
|
||||
}
|
||||
|
||||
if (result.y > splitPos.y) {
|
||||
result.y -= (pixelOrigin.y - mapPanePos.y);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
layerPointToContainerPointIgnoreSplits: function (point) { // (Point)
|
||||
return L.point(point).add(this._getMapPanePos());
|
||||
},
|
||||
|
||||
|
@ -925,6 +972,15 @@ L.Map = L.Evented.extend({
|
|||
return this.layerPointToLatLng(layerPoint);
|
||||
},
|
||||
|
||||
containerPointToLatLngIgnoreSplits: function (point) {
|
||||
var layerPoint = this.containerPointToLayerPointIgnoreSplits(L.point(point));
|
||||
return this.layerPointToLatLng(layerPoint);
|
||||
},
|
||||
|
||||
latLngToContainerPointIgnoreSplits: function (latlng) {
|
||||
return this.layerPointToContainerPointIgnoreSplits(this.latLngToLayerPoint(L.latLng(latlng)));
|
||||
},
|
||||
|
||||
latLngToContainerPoint: function (latlng) {
|
||||
return this.layerPointToContainerPoint(this.latLngToLayerPoint(L.latLng(latlng)));
|
||||
},
|
||||
|
@ -1624,7 +1680,7 @@ L.Map = L.Evented.extend({
|
|||
|
||||
// layer point of the current center
|
||||
_getCenterLayerPoint: function () {
|
||||
return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
|
||||
return this.containerPointToLayerPointIgnoreSplits(this.getSize()._divideBy(2));
|
||||
},
|
||||
|
||||
// offset of the specified place to the current center in pixels
|
||||
|
|
Loading…
Reference in a new issue