Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redraw restrictions panel when dragging sidebar #5502

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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