我需要一點幫助。 在下面的代碼中,我想通過onmouse-event來控制星的旋轉。通過Javascript停止/啓動SVG旋轉
如果將鼠標移動到星形上,它應該旋轉。
我想到了在attributeName
改變transform
不同的東西,當鼠標不超過通過roationon()/off()
功能的明星,這樣的旋轉不工作,但我不知道該怎麼做。
我很感激我能得到的每一個幫助。
感謝
<!DOCTYPE html>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<html>
<body>
<script>
function rotationon() {}
function rotationoff() {}
</script>
<svg height="2000" width="2000">
<polygon id="stern1" points="100,10 40,180 190,60 10,60 160,180" fill="yellow" transform="translate(100, 100)" onmouseover="rotationon()" onmouseout="rotationoff()" >
<animateTransform
attributeName="transform"
begin="0s"
dur="5s"
type="rotate"
from="0 100 100"
to="360 100 100"
repeatCount="indefinite"
/>
</polygon>
</svg>
</body>
</html>
只是出於興趣,如果多數民衆贊成在所有你想要做的,你可以做到這一點沒有JavaScript,像http://jsfiddle.net/xaM6q/,但我懷疑你想要一個更好的解決方案來定製其他位。 – Ian