Advertisement
dhshin

transition_fin

Mar 21st, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.02 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta name="viewport" content="width=device-width">
  6.   <title>JS Bin</title>
  7. </head>
  8. <body>
  9.   <svg height='600' width='600'></svg>
  10.   <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js">
  11.   </script>
  12.   <script>
  13.    
  14.     let svg = d3.select('svg');
  15.     let circle =
  16.         svg
  17.           .append('circle')
  18.           .attr('fill', 'red');
  19.    
  20.     repeat();
  21.    
  22.     function repeat() {
  23.       circle
  24.         .attr('cx', 50)
  25.         .attr('cy', 50)
  26.         .attr('r', 10)
  27.       .transition()
  28.         .delay(500)
  29.         .duration(3000)
  30.         .attr('cx', 300)
  31.         .attr('cy', 300)
  32.         .attr('r', 100)
  33.         .attr('fill', 'black')
  34.         .ease(d3.easeElastic)
  35.       .transition()
  36.         .delay(500)
  37.         .duration(3000)
  38.         .attr('cx', 50)
  39.         .attr('cy', 50)
  40.         .attr('fill', 'red')
  41.         .attr('r', 10)
  42.         .ease(d3.easeCircle)
  43.       .on('end', repeat);
  44.     }
  45.    
  46.   </script>
  47.  
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement