mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Account for the width of open panes when centering the map on issues
This commit is contained in:
@@ -114,7 +114,7 @@ export function coreValidator(context) {
|
||||
|
||||
if (extent) {
|
||||
var setZoom = Math.max(context.map().zoom(), 19);
|
||||
context.map().centerZoomEase(extent.center(), setZoom);
|
||||
context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
|
||||
|
||||
// select the first entity
|
||||
if (issue.entityIds && issue.entityIds.length) {
|
||||
|
||||
@@ -738,6 +738,21 @@ export function rendererMap(context) {
|
||||
return map;
|
||||
};
|
||||
|
||||
map.unobscuredCenterZoomEase = function(loc, zoom) {
|
||||
var offset = map.unobscuredOffset();
|
||||
var locPx = projection(loc);
|
||||
var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]];
|
||||
var offsetLoc = projection.invert(offsetLocPx);
|
||||
map.centerZoomEase(offsetLoc, zoom);
|
||||
};
|
||||
|
||||
map.unobscuredOffset = function() {
|
||||
var openPane = d3_select('.map-panes .map-pane.shown');
|
||||
if (!openPane.empty()) {
|
||||
return [openPane.node().offsetWidth/2, 0];
|
||||
}
|
||||
return [0, 0];
|
||||
};
|
||||
|
||||
map.zoom = function(z2) {
|
||||
if (!arguments.length) {
|
||||
|
||||
@@ -102,7 +102,7 @@ export function uiEntityIssues(context) {
|
||||
var extent = d.extent(context.graph());
|
||||
if (extent) {
|
||||
var setZoom = Math.max(context.map().zoom(), 19);
|
||||
context.map().centerZoomEase(extent.center(), setZoom);
|
||||
context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user