From 42aa834fab6f448359f7df1557edc18eb81e7d29 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 6 Nov 2018 17:03:58 -0500 Subject: [PATCH] Avoid obscuring selected entity when expanding the sidebar --- modules/ui/sidebar.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/ui/sidebar.js b/modules/ui/sidebar.js index b0836acbd..cf5064bdc 100644 --- a/modules/ui/sidebar.js +++ b/modules/ui/sidebar.js @@ -165,10 +165,23 @@ export function uiSidebar(context) { sidebar.hover = _throttle(hover, 200); + sidebar.intersects = function(extent) { + var rect = selection.node().getBoundingClientRect(); + return extent.intersects([ + context.projection.invert([0, rect.height]), + context.projection.invert([rect.width, 0]) + ]); + }; + + sidebar.select = function(id, newFeature) { if (!_current && id) { - // uncollapse the sidebar to show the editor - sidebar.expand(true); + // uncollapse the sidebar + if (selection.classed('collapsed')) { + var entity = context.entity(id); + var extent = entity.extent(context.graph()); + sidebar.expand(sidebar.intersects(extent)); + } featureListWrap .classed('inspector-hidden', true); @@ -294,6 +307,7 @@ export function uiSidebar(context) { sidebar.hover = function() {}; sidebar.hover.cancel = function() {}; + sidebar.intersects = function() {}; sidebar.select = function() {}; sidebar.show = function() {}; sidebar.hide = function() {};