diff --git a/modules/behavior/breathe.js b/modules/behavior/breathe.js index b3ebaf0ec..191165c2e 100644 --- a/modules/behavior/breathe.js +++ b/modules/behavior/breathe.js @@ -117,6 +117,7 @@ export function behaviorBreathe() { if (_done || currSelected.empty()) { _selected.call(reset); + _selected = d3_select(null); return; } @@ -139,11 +140,14 @@ export function behaviorBreathe() { surface.call(run, toFrom); didCallNextRun = true; } + + // if entity was deselected, remove breathe styling + if (!d3_select(this).classed('selected')) { + reset(d3_select(this)); + } }); } - var _isInstalled = false; - function behavior(surface) { _done = false; _timer = d3_timer(function() { @@ -156,11 +160,15 @@ export function behaviorBreathe() { _timer.stop(); return true; }, 20); - _isInstalled = true; } - behavior.isInstalled = function() { - return _isInstalled; + behavior.restartIfNeeded = function(surface) { + if (_selected.empty()) { + surface.call(run, 'from'); + if (_timer) { + _timer.stop(); + } + } }; behavior.off = function() { @@ -171,7 +179,6 @@ export function behaviorBreathe() { _selected .interrupt() .call(reset); - _isInstalled = false; }; diff --git a/modules/modes/select.js b/modules/modes/select.js index 723e76b3a..2b704fe13 100644 --- a/modules/modes/select.js +++ b/modules/modes/select.js @@ -321,7 +321,10 @@ export function modeSelect(context, selectedIDs) { context.map() .on('move.select', closeMenu) .on('drawn.select', selectElements) - .on('crossEditableZoom.select', selectElements); + .on('crossEditableZoom.select', function() { + selectElements(); + breatheBehavior.restartIfNeeded(context.surface()); + }); context.surface() .on('dblclick.select', dblclick); @@ -421,7 +424,7 @@ export function modeSelect(context, selectedIDs) { } if (context.map().withinEditableZoom()) { - // Only apply selection styling if not in wide selection + // Apply selection styling if not in wide selection surface .selectAll(utilDeepMemberSelector(selectedIDs, context.graph())) @@ -429,15 +432,6 @@ export function modeSelect(context, selectedIDs) { surface .selectAll(utilEntityOrDeepMemberSelector(selectedIDs, context.graph())) .classed('selected', true); - - if (!breatheBehavior.isInstalled()) { - context.install(breatheBehavior); - } - - } else { - if (breatheBehavior.isInstalled()) { - context.uninstall(breatheBehavior); - } } }