Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active August 27, 2019 09:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmota/3faa2a2954f5249f61d9 to your computer and use it in GitHub Desktop.
Save miguelmota/3faa2a2954f5249f61d9 to your computer and use it in GitHub Desktop.
D3 callback when all transitions are done
function endAll(transition, callback) {
var n = 0
transition.each(() => ++n)
.each('end', () => (!--n && callback.apply(this, arguments)))
}
// Usage
// d3.selectAll('g').transition().call(endAll, allDone)
@nrmtmt
Copy link

nrmtmt commented Aug 27, 2019

@phocks you literally saved my life

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment