





















@@ -34,7 +34,7 @@ Previous Version: [https://github.com/webplatformco/project-image-animation/blob
34343. [Other Alternatives](#other-alternatives)
3535</details>
363637-## User Needs & Use Cases {#user-needs--use-cases}
37+## User Needs & Use Cases <a id="user-needs--use-cases"></a>
3838Animated images (as enabled by GIF, APNG, WebP) are in common use on the web,
3939for a variety of reasons, such as:
4040* Purely decorative design elements
@@ -97,9 +97,9 @@ But this is not always practical:
9797 being able to work directly with the markup's `<img>` tags
9898 is far easier than trying to replace them on the fly with something else.
9999100-## User Research {#user-research}
100+## User Research <a id="user-research"></a>
101101102-### Developer & User Signals {#developer--user-signals}
102+### Developer & User Signals <a id="developer--user-signals"></a>
103103A few examples amongst many of people asking for that type of functionality.
104104* Stack overflow:
105105[1](https://stackoverflow.com/questions/20644209/play-gif-on-mouseover-and-pause-gif-on-mouse-out-without-replacing-images)
@@ -113,24 +113,24 @@ A few examples amongst many of people asking for that type of functionality.
113113[1](https://old.reddit.com/r/HTML/comments/3hjccx/how_can_i_animate_and_stop_gifs_with_mouse_hover/)
114114[2](https://old.reddit.com/r/FirefoxCSS/comments/1523xwr/stop_animated_gifs_play_on_hoverclick/)
115115116-### Current Workarounds {#current-workarounds}
116+### Current Workarounds <a id="current-workarounds"></a>
117117Numerous workarounds exist (further highlighting author/user demand),
118118all with a variety of downsides.
119119See the [“Current Workarounds” section of the Images-in-video explainer](../images-in-video#user-content-current-workarounds) for a brief discussion.
120120121-## Goals {#goals}
121+## Goals <a id="goals"></a>
122122* Provide declarative syntax to enable/disable animation of images
123123* Handle images that are part of the content as well as decorative images
124124* Enable applying different settings to different images
125125* Enable simple user interactions (e.g. click to play)
126126* Work with existing markup and/or without
127127128-### Non-goals {#non-goals}
128+### Non-goals <a id="non-goals"></a>
129129* Turning animated images into fully fledged video player.
130130 (This [could be pursued separately](../images-in-video/README.md),
131131 but is not the focus of this explainer.)
132132133-## Proposed Solution {#proposed-solution}
133+## Proposed Solution <a id="proposed-solution"></a>
134134135135The proposed solution is a css property to control animation of images.
136136At its most basic version, it would take the following form:
@@ -176,7 +176,7 @@ all values have the same effect (i.e. none).
176176 the image animation plays,
177177 without synchronization with any other instance of the same image on the page.
178178179-### Sample Code Snippets {#sample-code-snippets}
179+### Sample Code Snippets <a id="sample-code-snippets"></a>
180180Turn off all image animations on the page:
181181```css
182182:root { image-animation: paused; }
@@ -222,7 +222,7 @@ Interesting effects can easily be achieved in combination with other CSS:
222222.carousel img:snapped { image-animation: play; }
223223```
224224225-### Beyond the Basics {#beyond-the-basics}
225+### Beyond the Basics <a id="beyond-the-basics"></a>
226226227227A key limitation of the above property is encountered
228228when authors want to set up a means for users
@@ -236,7 +236,7 @@ to activate the animation.
236236Two approaches are being considered to complement the basic design above.
237237238238239-#### High-level Approach {#high-level-solution}
239+#### High-level Approach <a id="high-level-solution"></a>
240240241241An additional value can be added to the `image-animation` property:
242242* **controlled**:
@@ -270,7 +270,7 @@ Same as above, in response to a [user request for reduced motion](https://drafts
270270```
271271272272273-#### Low-level Approach {#low-level-solution}
273+#### Low-level Approach <a id="low-level-solution"></a>
274274275275The `:animated-image` pseudo-class can be introduced,
276276and represents content image elements
@@ -286,9 +286,9 @@ without having to modify the DOM to add additional markup,
286286an `::overlay` pseudo-element could be added to `<img>`
287287enabling generated content or other effects to be easily placed over the image.
288288289-### Possible Extensions {#possible-extensions}
289+### Possible Extensions <a id="possible-extensions"></a>
290290291-#### Control Over Iterations {#control-over-iterations}
291+#### Control Over Iterations <a id="control-over-iterations"></a>
292292Animated image formats such as GIF, WebP, or APNG include information
293293about how many times the animation is supposed to run.
294294This could be made into an overridable default, with alternate possibilities being specified in CSS.
@@ -325,7 +325,7 @@ when the element is focused or hovered.
325325}
326326```
327327328-#### Longhands And Further Controls {#longhands-and-further-controls}
328+#### Longhands And Further Controls <a id="longhands-and-further-controls"></a>
329329The property above could be broken down into longhands
330330possibly similar to those of the `animation-*` family of properties
331331(`image-animation-play-state`, `image-animation-iteration-count`).
@@ -341,12 +341,12 @@ For instance,
341341`loop` in `animation-iteration-count` is actually called `infinite`,
342342and `once` would be `1`.
343343344-#### Control Over the Paused State {#control-over-the-paused-state}
344+#### Control Over the Paused State <a id="control-over-the-paused-state"></a>
345345The `paused` value could be extended to give control over which frame of the image is displayed when it is stopped.
346346347347`paused [ first | last | last-shown | <time> | <percent> | <number> ] ?`
348348349-### Accessibility Considerations {#accessibility-considerations}
349+### Accessibility Considerations <a id="accessibility-considerations"></a>
350350* Web pages can already contain animated images,
351351 and appropriate `alt` text is already expected to be provided.
352352 ”Cartoon coyote being squashed by a falling anvil“
@@ -368,7 +368,7 @@ The `paused` value could be extended to give control over which frame of the ima
368368`overflow: auto` / `scroll` makes elements focusable,
369369 only when there is something to scroll.
370370371-### Privacy Considerations {#privacy-considerations}
371+### Privacy Considerations <a id="privacy-considerations"></a>
372372With regards to decorative images,
373373this property enables control over image animation cross origin,
374374without leaking any information about whether the image is actually animatable or not.
@@ -409,9 +409,9 @@ We argue that this is an acceptable trade-off:
409409 If implemented, it means the situation would not just be analogous,
410410 but that whether an image is animatable would already be knowable cross-origin anyway.
411411412-## Complementary Solutions {#complementary-solutions}
412+## Complementary Solutions <a id="complementary-solutions"></a>
413413414-### Images in the `<video>` Element {#images-in-the-video-element}
414+### Images in the `<video>` Element <a id="images-in-the-video-element"></a>
415415See [the explainer for “Images in `<video>`”](../images-in-video/README.md).
416416417417Animated images are effectively videos without a sound track.
@@ -427,14 +427,14 @@ Pursuing both would make sense.
427427428428***…insert summary table showing overlap and differences…***
429429430-### What About `<img control>`? {#what-about-img-control}
430+### What About `<img control>`? <a id="what-about-img-control"></a>
431431432432***…insert discussion of why that's not a full substitute,
433433but of how both features can be made compatible with each other if that's desired…***
434434435-## Rejected Alternatives {#rejected-alternatives}
435+## Rejected Alternatives <a id="rejected-alternatives"></a>
436436437-### Provide this as a UA Setting {#provide-this-as-a-ua-setting}
437+### Provide this as a UA Setting <a id="provide-this-as-a-ua-setting"></a>
438438Firefox's `about:config` has `image.animation_mode`,
439439which can turn off all image animations,
440440and Safari respects macOS's “auto-play animated images” setting (default on, can be turn off).
@@ -476,7 +476,7 @@ More interestingly, the setting could be reinterpreted in terms of the CSS prope
476476}
477477```
478478479-### Reuse the Existing `animation-*` Properties {#reuse-the-existing-animation--properties}
479+### Reuse the Existing `animation-*` Properties <a id="reuse-the-existing-animation--properties"></a>
480480Properties like `animation-play-state: running | paused`
481481or `animation-iteration-count: infinite | <number [0,∞]>`
482482have value space that are similar to what is proposed here.
@@ -505,7 +505,7 @@ If the regular `animation-*` properties cannot be made to apply by default and w
505505it makes little sense to try and shoehorn image animations into them,
506506even if there are similarities.
507507508-### Other Alternatives {#other-alternatives}
508+### Other Alternatives <a id="other-alternatives"></a>
509509510510***This section is a work in progress.***
511511此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。