Skip to content

Commit

Permalink
Only redraw restrictions panel every 10px sidebar is dragged
Browse files Browse the repository at this point in the history
  • Loading branch information
jguthrie100 committed Nov 21, 2018
1 parent 5fc3126 commit 2bed29d
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions modules/ui/fields/restrictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function uiFieldRestrictions(field, context) {
var _intersection;
var _fromWayID;

var _redrawHandler;
var _lastXPos;


function restrictions(selection) {
Expand Down Expand Up @@ -332,7 +332,7 @@ export function uiFieldRestrictions(field, context) {

document.addEventListener('resizeWindow', function (e) {
utilSetDimensions(_container, null);
redraw();
redraw(10);
}, false);

updateHints(null);
Expand Down Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -661,8 +671,6 @@ export function uiFieldRestrictions(field, context) {

d3_select(window)
.on('resize.restrictions', null);

clearInterval(_redrawHandler);
};


Expand Down

0 comments on commit 2bed29d

Please sign in to comment.