svg 转圈圈
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <!doctype html> <html lang="en">
<head> <meta charset="UTF-8"> <title>动画效果</title> <!--此处填写代码--> <style> svg { cursor:pointer; } </style> </head>
<body> <svg width="320" height="200" xmlns="http://www.w3.org/2000/svg"> <text font-family="microsoft yahei" font-size="40" y="60" x="100">love <!--此处填写代码--> <animateTransform attributeType="XML" attributeName="transform" begin="0s" dur="3s" type="rotate" from="0 150,120" to="360 150,120" repeatCount="indefinite" /> <animateTransform attributeType="XML" attributeName="transform" begin="0s" dur="3s" type="scale" from="1 1 " to="1.5 1.5" repeatCount="indefinite" additive="sum" /> </text> </svg> <script> //此处填写代码 window.onload=function() { var svg=document.querySelector("svg"), state=1; svg.addEventListener("click",function() { if(state===1) { state=0; this.pauseAnimations(); } else{ state=1; this.unpauseAnimations(); } })
} </script> </body>
</html>
|
additive=”sum” 可以控制动画是否为加法