Fix performance issue where breathe behavior would be called for each selected element instead of just for the surface (close #3571)

This commit is contained in:
Quincy Morgan
2019-12-10 13:42:11 -05:00
parent 5cab4b1386
commit 4b4ea122ad
+8 -1
View File
@@ -126,12 +126,19 @@ export function behaviorBreathe() {
_selected = currSelected.call(calcAnimationParams);
}
var didCallNextRun = false;
_selected
.transition()
.duration(duration)
.call(setAnimationParams, fromTo)
.on('end', function() {
surface.call(run, toFrom);
// `end` event is called for each selected element, but we want
// it to run only once
if (!didCallNextRun) {
surface.call(run, toFrom);
didCallNextRun = true;
}
});
}