end - SVG: Scalable Vector Graphics 编辑

The end attribute defines an end value for the animation that can constrain the active duration.

Five elements are using this attribute: <animate>, <animateColor>, <animateMotion>, <animateTransform>, and <set>

Usage notes

Default valueNone
Value<end-value-list>
AnimatableNo

The <end-value-list> is a semicolon-separated list of values. Each value can be one of the following:

<offset-value>
This value defines a clock-value that represents a point in time relative to the beginning of the SVG document (usually the load or DOMContentLoaded event). Negative values are valid.
<syncbase-value>
This value defines a syncbase and an optional offset from that syncbase. The element's animation end time is defined relative to the begin or active end of another animation.
A valid syncbase-value consists of an ID reference to another animation element followed by a dot and either begin or end to identify whether to synchronize with the beginning or active end of the referenced animation element. An optional offset value as defined in <offset-value> can be appended.
<event-value>
This value defines an event and an optional offset that determines the time at which the element's animation should end. The animation end time is defined relative to the time that the specified event is fired.
A valid event-value consists of an element ID followed by a dot and one of the supported events for that element. All valid events (not necessarily supported by all elements) are defined by the DOM and HTML specifications. Those are: focus, blur, focusin, focusout, activate, auxclick, click, dblclick, mousedown, mouseenter, mouseleave, mousemove, mouseout, mouseover, mouseup, wheel, beforeinput, input, keydown, keyup, compositionstart, compositionupdate, compositionend, load, unload, abort, error, select, resize, scroll, beginEvent, endEvent, and repeatEvent . An optional offset value as defined in <offset-value> can be appended.
<repeat-value>
This value defines a qualified repeat event. The element animation end time is defined relative to the time that the repeat event is raised with the specified iteration value.
A valid repeat value consists of an element ID followed by a dot and the function repeat() with an integer value specifying the number of repetitions as parameter. An optional offset value as defined in <offset-value> can be appended.
<accessKey-value>
This value defines an access key that should trigger the end of the animation. The element animation will end when the user presses the specified key.
A valid accessKey-value consists of the function accessKey() with the character to be input as parameter. An optional offset value as defined in <offset-value> can be appended.
<wallclock-sync-value>
This value defines the animation end time as a real-world clock time.
A valid wallclock-sync-value consists of the function wallclock() with a time value as parameter. The time syntax is based upon the syntax defined in ISO 8601.
indefinite
The end of the animation will be determined by an SVGAnimationElement.endElement() method call.

Examples

Offset example

<svg width="120" height="120"  viewBox="0 0 120 120"
     xmlns="http://www.w3.org/2000/svg" version="1.1">

    <!-- animated rectangles -->
    <rect x="10" y="35" height="15" width="0">
        <animate attributeType="XML" attributeName="width" to="100"
                 begin="0s" end="8s"
                 fill="freeze" />
    </rect>

    <rect x="10" y="60" height="15" width="0">
        <animate attributeType="XML" attributeName="width" to="75"
                 begin="0s" end="6s"
                 fill="freeze" />
    </rect>

    <rect x="10" y="85" height="15" width="0">
        <animate attributeType="XML" attributeName="width" to="50"
                 begin="0s" end="4s"
                 fill="freeze" />
    </rect>

    <!-- grid -->
    <text x="10" y="20" text-anchor="middle">0s</text>
    <line x1="10" y1="25" x2="10" y2="105" stroke="grey" stroke-width=".5" />
    <text x="35" y="20" text-anchor="middle">2s</text>
    <line x1="35" y1="25" x2="35" y2="105" stroke="grey" stroke-width=".5" />
    <text x="60" y="20" text-anchor="middle">4s</text>
    <line x1="60" y1="25" x2="60" y2="105" stroke="grey" stroke-width=".5" />
    <text x="85" y="20" text-anchor="middle">6s</text>
    <line x1="85" y1="25" x2="85" y2="105" stroke="grey" stroke-width=".5" />
    <text x="110" y="20" text-anchor="middle">8s</text>
    <line x1="110" y1="25" x2="110" y2="105" stroke="grey" stroke-width=".5" />

    <line x1="10" y1="30" x2="110" y2="30" stroke="grey" stroke-width=".5" />
    <line x1="10" y1="105" x2="110" y2="105" stroke="grey" stroke-width=".5" />
</svg>

Event example

<svg width="120" height="120"  viewBox="0 0 120 120"
     xmlns="http://www.w3.org/2000/svg" version="1.1"
     xmlns:xlink="http://www.w3.org/1999/xlink">

    <!-- animated rectangle -->
    <rect x="10" y="35" height="15" width="0">
        <animate attributeType="XML" attributeName="width" from="0" to="100"
                 begin="0s" end="endButton.click" dur="8s"
                 repeatCount="indefinite" fill="freeze" />
    </rect>

    <!-- trigger -->
    <rect id="endButton" style="cursor:pointer;"
          x="19.5" y="62.5" rx="5" height="25" width="80"
          fill="#EFEFEF" stroke="black" stroke-width="1" />

    <text x="60" y="80" text-anchor="middle"
          style="pointer-events:none;">Click me.</text>

    <!-- grid -->
    <text x="10" y="20" text-anchor="middle">0s</text>
    <line x1="10" y1="25" x2="10" y2="55" stroke="grey" stroke-width=".5" />
    <text x="35" y="20" text-anchor="middle">2s</text>
    <line x1="35" y1="25" x2="35" y2="55" stroke="grey" stroke-width=".5" />
    <text x="60" y="20" text-anchor="middle">4s</text>
    <line x1="60" y1="25" x2="60" y2="55" stroke="grey" stroke-width=".5" />
    <text x="85" y="20" text-anchor="middle">6s</text>
    <line x1="85" y1="25" x2="85" y2="55" stroke="grey" stroke-width=".5" />
    <text x="110" y="20" text-anchor="middle">8s</text>
    <line x1="110" y1="25" x2="110" y2="55" stroke="grey" stroke-width=".5" />

    <line x1="10" y1="30" x2="110" y2="30" stroke="grey" stroke-width=".5" />
    <line x1="10" y1="55" x2="110" y2="55" stroke="grey" stroke-width=".5" />
</svg>

Accesskey example

<svg width="120" height="120"  viewBox="0 0 120 120"
     xmlns="http://www.w3.org/2000/svg" version="1.1"
     xmlns:xlink="http://www.w3.org/1999/xlink">

    <!-- animated rectangles -->
    <rect x="10" y="35" height="15" width="0">
        <animate attributeType="XML" attributeName="width" from="0" to="100"
                 begin="0s" end="accessKey(e)" dur="8s"
                 repeatCount="indefinite" fill="freeze" />
    </rect>

    <!-- trigger -->
    <text x="60" y="80" text-anchor="middle"
          style="pointer-events:none;">Hit the "s" key</text>

    <!-- grid -->
    <text x="10" y="20" text-anchor="middle">0s</text>
    <line x1="10" y1="25" x2="10" y2="55" stroke="grey" stroke-width=".5" />
    <text x="35" y="20" text-anchor="middle">2s</text>
    <line x1="35" y1="25" x2="35" y2="55" stroke="grey" stroke-width=".5" />
    <text x="60" y="20" text-anchor="middle">4s</text>
    <line x1="60" y1="25" x2="60" y2="55" stroke="grey" stroke-width=".5" />
    <text x="85" y="20" text-anchor="middle">6s</text>
    <line x1="85" y1="25" x2="85" y2="55" stroke="grey" stroke-width=".5" />
    <text x="110" y="20" text-anchor="middle">8s</text>
    <line x1="110" y1="25" x2="110" y2="55" stroke="grey" stroke-width=".5" />

    <line x1="10" y1="30" x2="110" y2="30" stroke="grey" stroke-width=".5" />
    <line x1="10" y1="55" x2="110" y2="55" stroke="grey" stroke-width=".5" />
</svg>

This example is embed in an iFrame. If you want to activate the key events, you have to click on it first.

Specifications

SpecificationStatusComment
SVG Animations Level 2
The definition of 'end' in that specification.
Editor's DraftNo change
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'end' in that specification.
RecommendationInitial definition

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:46 次

字数:17816

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文