From c002ab8b1d5e95489e8caf7c0bd017644d7cbd1e Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Wed, 21 Nov 2018 08:56:43 +0000 Subject: [PATCH] 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 bfe021515..5cdad80c8 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); };