Path: blob/main/files/en-us/web/svg/element/animatemotion/index.md
6581 views
------{{SVGRef}}
The SVG <animateMotion> element provides a way to define how an element moves along a motion path.
Note: To reuse an existing path, it will be necessary to use an {{SVGElement("mpath")}} element inside the
<animateMotion>element instead of the {{SVGAttr("path")}} attribute.
Example
{{EmbedLiveSample('Example', 150, '100%')}}
Usage context
{{svginfo}}
Attributes
{{SVGAttr("keyPoints")}}
: This attribute indicate, in the range [0,1], how far is the object along the path for each {{SVGAttr("keyTimes")}} associated values. Value type: <number>*; Default value: none; Animatable: no
{{SVGAttr("path")}}
: This attribute defines the path of the motion, using the same syntax as the {{SVGAttr('d')}} attribute. Value type: <string>; Default value: none; Animatable: no
{{SVGAttr("rotate")}}
: This attribute defines a rotation applied to the element animated along a path, usually to make it pointing in the direction of the animation. Value type: <number>|
auto|auto-reverse; Default value:0; Animatable: no
Note: For
<animateMotion>, the default value for the {{SVGAttr("calcMode")}} attribute ispaced.
Animation Attributes
: {{SVGAttr("begin")}}, {{SVGAttr("dur")}}, {{SVGAttr("end")}}, {{SVGAttr("min")}}, {{SVGAttr("max")}}, {{SVGAttr("restart")}}, {{SVGAttr("repeatCount")}}, {{SVGAttr("repeatDur")}}, {{SVGAttr("fill")}}
: {{SVGAttr("calcMode")}}, {{SVGAttr("values")}}, {{SVGAttr("keyTimes")}}, {{SVGAttr("keySplines")}}, {{SVGAttr("from")}}, {{SVGAttr("to")}}, {{SVGAttr("by")}}
: Most notably: {{SVGAttr("attributeName")}}, {{SVGAttr("additive")}}, {{SVGAttr("accumulate")}}
: Most notably: {{SVGAttr("onbegin")}}, {{SVGAttr("onend")}}, {{SVGAttr("onrepeat")}}
Global attributes
: Most notably: {{SVGAttr('id')}}
: {{SVGAttr('class')}}, {{SVGAttr('style')}}
Event Attributes
Usage notes
This element implements the {{domxref("SVGAnimateMotionElement")}} interface.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
{{SVGElement("mpath")}}