Skip to content

Commit

Permalink
Merge pull request #5502 from jguthrie100/redraw_restrictions_on_side…
Browse files Browse the repository at this point in the history
…bar_drag

Redraw restrictions panel when dragging sidebar
  • Loading branch information
bhousel authored Nov 30, 2018
2 parents d5031be + 82bc803 commit 8b0e729
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
30 changes: 20 additions & 10 deletions modules/ui/fields/restrictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export function uiFieldRestrictions(field, context) {
var _intersection;
var _fromWayID;

var _lastXPos;


function restrictions(selection) {
_parent = selection;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -335,6 +330,11 @@ export function uiFieldRestrictions(field, context) {
.classed('related', true);
}

document.addEventListener('resizeWindow', function () {
utilSetDimensions(_container, null);
redraw(1);
}, 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
7 changes: 7 additions & 0 deletions modules/ui/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};


Expand Down
5 changes: 5 additions & 0 deletions modules/ui/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -97,6 +99,9 @@ export function uiSidebar(context) {
}
}
})
.on('end', function() {
resizer.classed('dragging', false);
})
);

var featureListWrap = selection
Expand Down

0 comments on commit 8b0e729

Please sign in to comment.