Search code examples
ajaxd3.jstransitionturbolinks

d3js: How to stop all transitions?


I have a web-application with d3js and turbolinks (ajax navigation).

Some of my pages contains a long-run transitions (over 100s), so when a part of the page was being reloaded with AJAX all the transitions from previous page are still running.

How can I completely remove all the transitions from the original page?

There is an event called "page:before-unload" in turbolinks so I'm planning to use it for the cleanup.


Solution

  • Looking at your comments, I think this will work:

    d3.selectAll('*').transition();
    

    But the transitions will be destroyed when the svg/canvas is destroyed, as Lars Kotthoff said, so there's no need for this if you're destroying the svg/canvas.