Implement cleaner solution for removing breathe styling from deselected features

This commit is contained in:
Quincy Morgan
2019-12-13 13:16:29 -05:00
parent 61f0a670db
commit 91b6844377
2 changed files with 18 additions and 17 deletions
+13 -6
View File
@@ -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;
};