Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add animation to D3 custom Radios

I have radios aligned on an arch.

I would like to add a transition that slides the selected inner blue dot along the arch to the newly selected radio.

IMAGE

I have a working demo setup. WORKING DEMO

like image 529
texas697 Avatar asked Mar 17 '21 13:03

texas697


1 Answers

See a solution in the fiddle (click on the blue button):

Just put the button in a "g" and rotate it with transition:

const button = d3.select("#button");
let angle = 60;

button.on("click", () => {
 angle = -angle;
 button.transition().duration(1000).attr("transform", `translate(${cX}, ${cY}) rotate(${angle})`);
});
like image 132
Michael Rovinsky Avatar answered Oct 01 '22 16:10

Michael Rovinsky