[英]how to add animation to D3 custom Radios
在小提琴中查看解决方案(单击蓝色按钮):
只需将按钮放在“g”中并使用过渡旋转它:
const button = d3.select("#button");
let angle = 60;
button.on("click", () => {
angle = -angle;
button.transition().duration(1000).attr("transform", `translate(${cX}, ${cY}) rotate(${angle})`);
});
另一种选择是沿路径使用animateMotion :
<svg width="300" height="200"> <path fill="none" stroke="blue" stroke-width="3" d="M 20,20 A 100,100 0 0 0 220,20" /> <circle r="10" fill="white" stroke="blue" stroke-width="3"> <animateMotion dur="3s" repeatCount="indefinite" path="M 20,20 A 100,100 0 0 0 220,20 A 100,100 1 1 1 20,20" /> </circle> </svg>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.