diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index df16c3f50..a26007001 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -66,6 +66,8 @@ export function uiFieldRestrictions(field, context) { var _intersection; var _fromWayID; + var _lastXPos; + function restrictions(selection) { _parent = selection; @@ -293,15 +295,8 @@ export function uiFieldRestrictions(field, context) { surface .call(breathe); - - d3_select(window) - .on('resize.restrictions', function() { - utilSetDimensions(_container, null); - redraw(); - }); } - // This can happen if we've lowered the detail while a FROM way // is selected, and that way is no longer part of the intersection. if (_fromWayID && !vgraph.hasEntity(_fromWayID)) { @@ -335,6 +330,11 @@ export function uiFieldRestrictions(field, context) { .classed('related', true); } + document.addEventListener('resizeWindow', function () { + utilSetDimensions(_container, null); + redraw(1); + }, false); + updateHints(null); @@ -435,10 +435,20 @@ export function uiFieldRestrictions(field, context) { updateHints(datum); } + _lastXPos = _lastXPos || sdims[0]; - function redraw() { - if (context.hasEntity(_vertexID)) { - _container.call(renderViewer); + function redraw(minChange) { + var xPos = -1; + + if (minChange) { + xPos = utilGetDimensions(d3_select('#sidebar'))[0]; + } + + if (!minChange || (minChange && Math.abs(xPos - _lastXPos) >= minChange)) { + if (context.hasEntity(_vertexID)) { + _lastXPos = xPos; + _container.call(renderViewer); + } } } diff --git a/modules/ui/init.js b/modules/ui/init.js index e1f5a02a3..cbea59be1 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -411,6 +411,13 @@ export function uiInit(context) { // check if header or footer have overflowed ui.checkOverflow('#bar'); ui.checkOverflow('#footer'); + + // Use outdated code so it works on Explorer + var resizeWindowEvent = document.createEvent('Event'); + + resizeWindowEvent.initEvent('resizeWindow', true, true); + + document.dispatchEvent(resizeWindowEvent); }; diff --git a/modules/ui/sidebar.js b/modules/ui/sidebar.js index c678a44ba..b12f97889 100644 --- a/modules/ui/sidebar.js +++ b/modules/ui/sidebar.js @@ -62,6 +62,8 @@ export function uiSidebar(context) { selection .style('width', widthPct + '%') // lock in current width .style('max-width', '85%'); // but allow larger widths + + resizer.classed('dragging', true); }) .on('drag', function() { var isRTL = (textDirection === 'rtl'); @@ -97,6 +99,9 @@ export function uiSidebar(context) { } } }) + .on('end', function() { + resizer.classed('dragging', false); + }) ); var featureListWrap = selection