Prevent partial rendering of selection style when showing only selected features at low zooms

This commit is contained in:
Quincy Morgan
2019-12-12 17:50:48 -05:00
parent 03cea6435a
commit ff506fc332
2 changed files with 33 additions and 14 deletions
+6
View File
@@ -142,6 +142,7 @@ export function behaviorBreathe() {
});
}
var _isInstalled = false;
function behavior(surface) {
_done = false;
@@ -155,8 +156,12 @@ export function behaviorBreathe() {
_timer.stop();
return true;
}, 20);
_isInstalled = true;
}
behavior.isInstalled = function() {
return _isInstalled;
};
behavior.off = function() {
_done = true;
@@ -166,6 +171,7 @@ export function behaviorBreathe() {
_selected
.interrupt()
.call(reset);
_isInstalled = false;
};
+27 -14
View File
@@ -40,10 +40,11 @@ export function modeSelect(context, selectedIDs) {
};
var keybinding = utilKeybinding('select');
var breatheBehavior = behaviorBreathe(context);
var behaviors = [
behaviorCopy(context),
behaviorPaste(context),
behaviorBreathe(context),
breatheBehavior,
behaviorHover(context),
behaviorSelect(context),
behaviorLasso(context),
@@ -403,25 +404,37 @@ export function modeSelect(context, selectedIDs) {
// Don't highlight selected features past the editable zoom
if (!context.map().withinEditableZoom()) {
if (breatheBehavior.isInstalled()) {
context.uninstall(breatheBehavior);
}
surface.selectAll('.selected').classed('selected', false);
surface.selectAll('.selected-member').classed('selected-member', false);
return;
}
var selection = context.surface()
.selectAll(utilEntityOrMemberSelector(selectedIDs, context.graph()));
} else if (context.map().withinEditableZoom()) {
if (selection.empty()) {
// Return to browse mode if selected DOM elements have
// disappeared because the user moved them out of view..
var source = d3_event && d3_event.type === 'zoom' && d3_event.sourceEvent;
if (drawn && source && (source.type === 'mousemove' || source.type === 'touchmove')) {
context.enter(modeBrowse(context));
var selection = context.surface()
.selectAll(utilEntityOrMemberSelector(selectedIDs, context.graph()));
if (selection.empty()) {
// Return to browse mode if selected DOM elements have
// disappeared because the user moved them out of view..
var source = d3_event && d3_event.type === 'zoom' && d3_event.sourceEvent;
if (drawn && source && (source.type === 'mousemove' || source.type === 'touchmove')) {
context.enter(modeBrowse(context));
}
} else {
selection
.classed('selected', true);
}
} else {
selection
.classed('selected', true);
if (!breatheBehavior.isInstalled()) {
context.install(breatheBehavior);
}
}
}