如何使用SVG实现这一点?如果你能帮忙的话,我将非常感激,谢谢。
HTML
<svg id="product-logo" on-click="onProductLogoClick_" width="27" height="27" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#a)" fill="#fff"><path d="M5.225 10.265A6.996 6.996 0 0 1 12 5h9.733a11.976 11.976 0 0 0-19.512.061l3.004 5.204zM22.898 7h-6.003a6.979 6.979 0 0 1 1.162 8.498l.008.004-4.872 8.438A11.98 11.98 0 0 0 22.898 7zm-9.009 11.735A6.964 6.964 0 0 1 5.944 15.5l-.004.002-4.87-8.435a11.98 11.98 0 0 0 9.812 16.877l3.007-5.21z"></path><path d="M12 17a5 5 0 1 0 0-10 5 5 0 0 0 0 10z"></path></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h24v24H0z"></path></clipPath></defs></svg>
JS
onProductLogoClick_() {
this.$["product-logo"].animate({
transform: ["none", "rotate(-10turn)"]
}, {
duration: 500,
easing: "cubic-bezier(1, 0, 0, 1)"
})
}
1条答案
按热度按时间vnjpjtjt1#
它只能在SVG中完成,并使用SMIL动画
更多精彩互动请参见:https://codepen.io/mikemjharris/post/svg-toggling