D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
tomshanley
Full window
Github gist
ease delay
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } </style> </head> <body> <script> console.clear() function delayEase(t, e) { // the polyInOut function from d3.ease // https://github.com/d3/d3-ease/blob/master/src/poly.js return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2; } let exp = 0.5 // see https://github.com/d3/d3-ease/blob/master/src/poly.js#L27 let arr = [0,1,2,3,4,5,6,7] let len = arr.length let svg = d3.select("body").append("svg") .attr("width", 1000) .attr("height", 500) let circles = svg.selectAll("circle") .data(arr) .enter() .append("circle") .attr("cx", d => (d * 40) + 40) .attr("cy", 50) .attr("r", 10) .style("fill", "black") circles.transition() .duration(5000) .delay(function(d,i) { let delay = 5000 * (delayEase((i/len), exp)) console.log(delay) return delay }) .attr("cy", 450) </script> </body>
https://d3js.org/d3.v4.min.js