Skip to content

Commit

Permalink
Fix performance issue where breathe behavior would be called for each…
Browse files Browse the repository at this point in the history
… selected element instead of just for the surface (close #3571)
  • Loading branch information
quincylvania committed Dec 10, 2019
1 parent 5cab4b1 commit 4b4ea12
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/behavior/breathe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
}

Expand Down

0 comments on commit 4b4ea12

Please sign in to comment.