From 6137941efdca2fe4956985b41b35ccd3438c9ba7 Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Mon, 19 Nov 2018 15:12:30 +0000 Subject: [PATCH 1/5] Redraw restrictions panel when dragging sidebar --- modules/ui/fields/restrictions.js | 12 ++++++++++++ modules/ui/sidebar.js | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index c0104a4d88..7c9fa09b8e 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 _redrawHandler; + function restrictions(selection) { _parent = selection; @@ -301,6 +303,14 @@ export function uiFieldRestrictions(field, context) { }); } + if (!_redrawHandler) { + _redrawHandler = setInterval(function() { + if (d3_select('#sidebar-resizer').classed('dragging')) { + utilSetDimensions(_container, null); + redraw(); + } + }, 50); + } // 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. @@ -661,6 +671,8 @@ export function uiFieldRestrictions(field, context) { d3_select(window) .on('resize.restrictions', null); + + clearInterval(_redrawHandler); }; diff --git a/modules/ui/sidebar.js b/modules/ui/sidebar.js index c678a44bae..b12f978891 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 From 5fc312620ff54f4683a0d8c334334d6c0229359f Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Tue, 20 Nov 2018 18:39:00 +0000 Subject: [PATCH 2/5] Converted to using custom Event --- modules/ui/fields/restrictions.js | 20 +++++--------------- modules/ui/init.js | 7 +++++++ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 7c9fa09b8e..bfe0215152 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -295,21 +295,6 @@ export function uiFieldRestrictions(field, context) { surface .call(breathe); - - d3_select(window) - .on('resize.restrictions', function() { - utilSetDimensions(_container, null); - redraw(); - }); - } - - if (!_redrawHandler) { - _redrawHandler = setInterval(function() { - if (d3_select('#sidebar-resizer').classed('dragging')) { - utilSetDimensions(_container, null); - redraw(); - } - }, 50); } // This can happen if we've lowered the detail while a FROM way @@ -345,6 +330,11 @@ export function uiFieldRestrictions(field, context) { .classed('related', true); } + document.addEventListener('resizeWindow', function (e) { + utilSetDimensions(_container, null); + redraw(); + }, false); + updateHints(null); diff --git a/modules/ui/init.js b/modules/ui/init.js index e1f5a02a30..700350945a 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 older code so it works on Explorer + var resizeWindowEvent = document.createEvent('Event'); + + resizeWindowEvent.initEvent('resizeWindow', true, true); + + document.dispatchEvent(resizeWindowEvent); }; From c002ab8b1d5e95489e8caf7c0bd017644d7cbd1e Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Wed, 21 Nov 2018 08:56:43 +0000 Subject: [PATCH 3/5] Only redraw restrictions panel every 10px sidebar is dragged --- modules/ui/fields/restrictions.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index bfe0215152..5cdad80c85 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -66,7 +66,7 @@ export function uiFieldRestrictions(field, context) { var _intersection; var _fromWayID; - var _redrawHandler; + var _lastXPos; function restrictions(selection) { @@ -330,9 +330,9 @@ export function uiFieldRestrictions(field, context) { .classed('related', true); } - document.addEventListener('resizeWindow', function (e) { + document.addEventListener('resizeWindow', function () { utilSetDimensions(_container, null); - redraw(); + redraw(10); }, 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); + } } } @@ -661,8 +671,6 @@ export function uiFieldRestrictions(field, context) { d3_select(window) .on('resize.restrictions', null); - - clearInterval(_redrawHandler); }; From 7bf4c462e842dcd4404997871670976671acfe2c Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Wed, 21 Nov 2018 09:13:54 +0000 Subject: [PATCH 4/5] Lowered redraw threshold to 2px --- modules/ui/fields/restrictions.js | 2 +- modules/ui/init.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 5cdad80c85..591838078c 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -332,7 +332,7 @@ export function uiFieldRestrictions(field, context) { document.addEventListener('resizeWindow', function () { utilSetDimensions(_container, null); - redraw(10); + redraw(2); }, false); updateHints(null); diff --git a/modules/ui/init.js b/modules/ui/init.js index 700350945a..cbea59be1b 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -412,7 +412,7 @@ export function uiInit(context) { ui.checkOverflow('#bar'); ui.checkOverflow('#footer'); - // Use older code so it works on Explorer + // Use outdated code so it works on Explorer var resizeWindowEvent = document.createEvent('Event'); resizeWindowEvent.initEvent('resizeWindow', true, true); From 82bc803bb03348aca287b6ac496ae4db8b9fed05 Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Mon, 26 Nov 2018 01:43:51 +0000 Subject: [PATCH 5/5] Lower redraw threshold to 1px --- modules/ui/fields/restrictions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 591838078c..4df77fe7c3 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -332,7 +332,7 @@ export function uiFieldRestrictions(field, context) { document.addEventListener('resizeWindow', function () { utilSetDimensions(_container, null); - redraw(2); + redraw(1); }, false); updateHints(null);