title | slug |
---|---|
animateMotion |
Web/SVG/Element/animateMotion |
{{SVGRef}}
<animateMotion>
元素定义了一个元素如何沿着运动路径进行移动。
Note
为了复用一个已经定义的路径,就有必要使用一个 {{SVGElement("mpath")}} 元素嵌入到 <animateMotion>
中,而不是使用 {{SVGAttr("path")}}。
html,
body,
svg {
height: 100%;
margin: 0;
padding: 0;
display: block;
}
<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">
<path fill="none" stroke="lightgrey"
d="M20,50 C20,-50 180,150 180,50 C180-50 20,150 20,50 z" />
<circle r="5" fill="red">
<animateMotion dur="10s" repeatCount="indefinite"
path="M20,50 C20,-50 180,150 180,50 C180-50 20,150 20,50 z" />
</circle>
</svg>
{{EmbedLiveSample('示例', 150, '100%')}}
{{svginfo}}
- 条件处理属性 »
- 核心属性 »
- 动画事件属性 »
- Xlink 属性 »
- 动画定时属性 »
- 动画值属性 »
- An 动画累加属性 »
- {{ SVGAttr("externalResourcesRequired") }}
- {{ SVGAttr("calcMode") }}
- {{ SVGAttr("path") }}
- {{ SVGAttr("keyPoints") }}
- {{ SVGAttr("rotate") }}
- {{ SVGAttr("origin") }}
该元素实现了 SVGAnimateMotionElement
接口。
{{Specifications}}
{{Compat}}
- {{ SVGElement("mpath") }}