Does d3 transitions and animations use requestAnimationFrame?

I am trying to find out if d3 uses requestAnimationFrame animation by default for a callback or if I need to do it myself. For example, I defined a custom animation that repeatedly calls the redraw function to animate the transition from one domain to another on the chart (this is in coffeescript):

 rd = @redraw # a function that takes an argument to redraw the graph @svg.transition() .duration(1000) .tween "zoom", -> interp = d3.interpolate(current_dom, target_dom) (t) -> rd interp(t) 

In all my other redraw calls, I plan it with requestAnimationFrame :

 scheduleRedraw: => # Stop a previous request if it hasn't executed yet cancelAnimationFrame(@animRequest) if @animRequest @animRequest = requestAnimationFrame => @redraw 

However, I wonder if I need to do the same here. I look at the source of d3 and see that the only reference to requestAnimationFrame is in the d3 timer class. Hope someone with some knowledge of d3 can answer the following questions:

  • Is the d3 timer used worldwide for all d3 animations and transitions?
  • Do I need to manually use requestAnimationFrame here? If not, is there a case when I will ever need to use it when using d3?
+8
javascript animation requestanimationframe
source share
1 answer

From the d3 wiki: Transitions: Timer

If your browser supports it, the timer queue will use requestAnimationFrame for fluid and efficient animation.

+8
source share

All Articles