restart
restart 屿§ã¯ãã¢ãã¡ã¼ã·ã§ã³ãåèµ·åã§ãããã©ããã示ãã¾ãã
ãã®å±æ§ã¯ã以ä¸ã® SVG è¦ç´ ã§ä½¿ç¨ãããã¨ãã§ãã¾ãã
ä¾
html
<svg viewBox="0 0 220 200" xmlns="http://www.w3.org/2000/svg">
<rect y="30" width="100" height="100">
<animate
attributeType="XML"
attributeName="y"
from="30"
to="100"
dur="5s"
repeatCount="1"
restart="always" />
</rect>
<rect x="120" y="30" width="100" height="100">
<animate
attributeType="XML"
attributeName="y"
from="30"
to="100"
dur="5s"
repeatCount="1"
restart="whenNotActive" />
</rect>
<a id="restart"><text y="20">Restart animation</text></a>
</svg>
js
document.getElementById("restart").addEventListener("click", (evt) => {
document.querySelectorAll("animate").forEach((element) => {
element.beginElement();
});
});
使ç¨ä¸ã®ã¡ã¢
| å¤ |
always | whenNotActive | never
|
|---|---|
| ããã©ã«ãå¤ | always |
| ã¢ãã¡ã¼ã·ã§ã³ | ä¸å¯ |
always-
ãã®å¤ã¯ãã¢ãã¡ã¼ã·ã§ã³ããã¤ã§ãåéãããã¨ãå¯è½ã§ãããã¨ã示ãã¦ãã¾ãã
whenNotActive-
ãã®å¤ã¯ãã¢ãã¡ã¼ã·ã§ã³ãã¢ã¯ãã£ãã§ãªãç¶æ ï¼ã¤ã¾ããã¢ã¯ãã£ãæéãçµäºããå¾ï¼ã§ã®ã¿ãã¢ãã¡ã¼ã·ã§ã³ãåèµ·åãããã¨ãã§ãããã¨ã示ãã¾ããã¢ãã¡ã¼ã·ã§ã³ã®ã¢ã¯ãã£ãæéä¸ã«åèµ·åã試ã¿ã¦ããç¡è¦ããã¾ãã
never-
ãã®å¤ã¯ãã¢ãã¡ã¼ã·ã§ã³ãåèµ·åã§ããªããã¨ã示ãã¦ãã¾ãã
仿§æ¸
| 仿§æ¸ |
|---|
| SVG Animations Level 2 > # RestartAttribute > |