We need to be able to control
Image Animation
on the Web Platform!

Animated Images

Classics

HUGO, BRIAN THE HAMSTER, JUSTINATWISTERFATTY BOOM BOOM SNOWBALLIZZYBUDQUIRBYTINKNORBYMELONHEADUNCLE EUGENEBOOGRHEAT1BEKY FIDGET,BONNIE,HENRY HOFFMANBOOTY SCOOTIN,              HEIDIEVIL FRANSTER                    ELECTRA GLIDEHANS HAMPTON HAMPSTERWEEZIEALEXKRISGUSGUSGEORGE THE TILTED HAMSTERSHUSHULINKYDINKYPRINCESS ROSABELLEHOLLANDHADO HAMSTER SIR HAMLET, OLGAPIGGIERATBOYWOODY TINKYKATIEBUBBAERLINE the GRAMMIE HAMSTER THUNDERFOOT MONET, the WONDER BIRD HUEYSHARONPHYLLIS

Memes

Emoticons

People still use GIFs‽

More than ever.

mind blown

UI Elements

animated checkbox
animated music play button
loading
Twitter like

Wikipedia

Rotating molecule of Benzatropine

Decorative Images

New Game

Rich Text Editing

Drag&drop inserts <img> tags

Dear AC forum,

What do you think of this as a new logo:

Problem for Users

Safari settings to turn off image animation Firefox settings to turn off image animation

Problem for Authors

Evidence of author interest:

Workarounds

Server-side

  • Server-side frame extraction, then swapping out
  • Server-side conversion to MP4, then using <video>
  • Computationally expensive

Client-side

  • Client-side frame extraction via <canvas>, then swapping out
  • Same-origin only

Solutions

Idea: image-animation property


		image-animation: normal | paused | running
	

Inherited, so you can do:


			@media (prefers-reduced-motion) {
			  :root {
			    image-animation: paused;
			  }
			}
			
Applies to:
  • Content images (<img>, <image> etc)
  • CSS images (any <image> value)
- `normal`: Current behavior - `running`: Playing, sans synchronization

Toggling playback


		@media (prefers-reduced-motion) {
		  :root {
		    image-animation: paused;
		  }

		  img:focus, img:hover {
		    image-animation: running;
		  }
		}
		

Focusability to be managed separately

Play

What authors want

Animated image with player

Idea: Images in <video>

<video src="meme.gif" controls loop muted></video>
Explainer, WHATWG issue

What about the opposite?

<img src="meme.gif" controls noloop noautoplay>

+ making HTMLImageElement implement HTMLMediaElement

Idea: High-level solution

Animated image with player

				image-animation: controlled;
			
  • Content images: UA-generated playback controls & automatic focusability
  • CSS images: same as paused
  • UA-generated UI (customizable with pseudo-elements)
  • tricky interaction with <img controls> if we ever decide to do it

Idea: Low-level solution

Animated image with player

Other ideas

image-frame() function

image-frame(<image> [at <percentage> | last-shown]?)

animation-* in @image *


		@image --pause-if-reduced-motion {
			@media (prefers-reduced-motion) {
				animation-play-state: paused;
			}
		}

		.foo {
			background-image: image(url(foo.gif) --pause-if-reduced-motion)
		}
	

* WG resolution for @image in 2022

Special animation-name value


		animation-name: image-animation(content), image-animation(background-image);
		animation-play-state: paused;