【发布时间】:2019-10-07 05:16:07
【问题描述】:
我正在构建一组SVG icons,我需要在 SVG 文件中包含动画 - 没有 Javascript 或没有 CSS。这个想法是拥有可以在我的 html 代码中添加的独立 SVG 文件,例如 <img src="my-icon.svg">
每个图标都有一组SMIL animations,包括简介、主要动画、事件触发动画和结尾。
SVG 文件如下所示:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64" ...>
<g id="group1" ...>
<path id="path1" d="M0-0l37.5,27,...">
<path id="path2" d="M0-0l37.5,27,...">
...
</g>
<g id="group2" ...>
...
</g>
<!-- Intro -->
<animate
id="animation1"
attributeName="opacity"
from="0"
to="1"
begin="2s"
dur="1.5s"
keySplines="1 0 1 1"
calcMode="spline"
/>
<!-- Animations -->
<animateTransform
id="animation2"
xlink:href="#arrows"
attributeName="transform"
type="translate"
from="..."
to="..."
begin="animation1.end - 1s"
dur="2s"
values="..."
keyTimes="..."
keySplines="..."
calcMode="spline"
repeatCount="3"
/>
<animate
...
/>
...
<!-- Outro -->
<animate
id="animationX"
attributeName="opacity"
from="1"
to="0"
begin="animation3.end - 1s"
dur="1.5s"
keySplines="0.5 0 1 0.5"
calcMode="spline"
/>
</svg>
这个例子展示了一个按时堆叠的动画,我想无限期地重复 - 我需要重复整个动画。
有什么想法吗?
【问题讨论】:
标签: html animation svg w3c smil