-
Notifications
You must be signed in to change notification settings - Fork 711
[css-images] Disabling image animation #1615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Perhaps add Some animation formats distinguish a still poster frame from the first frame. You would probably have to specify which would be used when. |
Yep, that definitely fits. The use-cases for it seem weaker, though, and with that level of control you might want a
Do you know which ones? (I imagine the answer would be the same as for canvas's |
APNG, for instance, can include PNG’s standard IDAT chunk data as the first frame or treat it as a fallback still image. |
Simon, thank you very much for opening this issue. I think it's much more than a "nice to have", though. The Web Content Accessibility Guidelines require that users be given the ability to pause, stop, or hide any animation that starts automatically and lasts more than 5 seconds (e.g. looping animated GIFs and PNGs). This is as it should be, since, for example, users with hypervigilance (little to no ability to employ selective attention) are unable to "just ignore" or "tune out" distracting extraneous animations in the field of view. Firefox (and previously Netscape), for example, originally had the ability to stop animated images by pressing the Stop button or hitting the Esc key. Then this ability was eliminated as a side effect of fixing an XMLHttpRequest bug, and now browser add-ons must be installed in order to restore it. Unfortunately these add-ons utilize browser hooks that will no longer be available when Firefox support for add-ons other than WebExtensions is eliminated in November 2017. Currently, WebExtensions and user stylesheet overrides have no ability to stop image animations, so it seems that a new CSS property is required to allow browsers like Firefox to meet this aspect of the W3C accessibility guidelines (and thus handle the myriad of sites whose webmasters do not implement the WCAGs). |
Firefox (or any browser) doesn't need a CSS property in order to control GIF/APNG playback. The current play position isn't even exposed to the web, except indirectly via what frames would get painted to a canvas at a given point in time. It's perfectly acceptable for a browser to give this sort of control natively, either thru a user setting or thru direct manipulation (stop/start gifs on click automatically). The only reason to add a CSS property is if we think that page authors need this control, and such control is common enough that things like |
Correct me if I'm wrong, but doesn't the same-origin poiicy render Also, the argument for using components like Not only does that seem far too convoluted for something which is effectively a "troll security" measure to protect against users trying to disrupt other users' browsing experience (much like how one should use CSS to prevent user-submitted long strings of characters from causing changes to the layout beyond the scope of their post), it also seems like a potential performance issue and a decision which would disincentivize doing the right thing. (And it would also be a solution ill-suited to "simple, static, meant-for-reading" pages (forums, wikis, etc.) where every other bit of mitigation for user-submitted content shenanigans (CSS, In that latter case, it encourages people like me to take the risk of feeding all user-provided image content through server-side reprocessing to strip extra frames. (At the risk of exposing a vulnerability in the underlying image library which might be leveraged into an exploit across all browsers which visit the site.) |
This suggests that you think site authors are going to be the ones using this property. I don't see why they would, tho. Gifs are generally just fine to upload alongside any other images. The need to stop/start a gif is either a per-user thing which should apply to all sites (and thus should be a browser setting), or should just generally be a functionality applied to all gifs for all users. I'm not seeing the use-case for an individual site author to need to turn on this functionality. |
Because I'm both someone with hypervigilance issues and a designer/developer with a strong desire to control when and where animated elements are allowed within the sites I produce. (If a muted Hence my comment about using image-processing libraries server-side. (To limit the risk, I've taken to using a simple a pre-check stage which detects APNG and animated GIFs using only very limited, defensively-coded inspection routines before I feed only the animated stuff to the full parser.) On my hobby sites, a lack of this has actually been one of the factors delaying a move away from full pre-moderation to a more wiki-like experience. |
This functionality seems to me as a natural extension of the Media Fragments URI spec, assuming browsers ever get on board with fully implementing that spec. Then you could use something like:
Using a URI hash to set the pause might help avoid the issue with HTML expecting all images with the same URL to animate in sync. The downside, of course, is that you'd need to modify every URL, and therefore use JS to re-enable animations on content images. Of course, it would also very much like a user-controlled browser feature to disable auto-playing GIFs, etc. But I do see a benefit to a website designer in being able to use these image formats but also being able to start and stop them. |
I don't know much about programming, but I get nasty migraines and other symptoms from flashing, zooming, and some other animation. Some people get seizures. So it can be important for users to be able to disable animation [including transform and transition and so on], easily, and before we get hit by the animation. |
That's a very good point. I would say, this is something the user should be in control of, not the website author. I.e. disabling all animations should rather be an option in the user agent than a CSS feature. Simon's use case is to allow to disable only image animations, and that selectively per image. Sebastian |
I think it makes more sense for it to be a matter of precedence. The user can overrule the website and the website can overrule the resource. (ie. I can disable all animation on a site, but even if I don't, the website should have the ability to disable animation on external or user-uploaded resources without having to incorporate potentially insecure libraries for reading and writing the formats in question in order to strip extra frames as is currently necessary.) |
Personally I don't know if this is needed, but to add a use-case, see |
At that level, it's something the UA should be applying, not something the page author is in charge of. That MQ is for alerting the author about things like animations and such, which are in their control and can't be automatically suppressed (since styling sometimes depends on them; just ignoring the animation can leave the element in an unusable default state). |
I'd love this, I maintain a PWA social media client that interfaces with multiple different servers, and not all of them offer static versions of images. Right now if I wanted to ensure all images are static I would need to render every image to a canvas before inserting it into the DOM, which is cumbersome and also breaks progressive image decoding. |
This could also be an HTML attribute, as only showing the first (or nth?) frame of a slideshow could be a content decision rather than a presentation one. Just as HTML attributes can determine when to load an image ( |
Use CasesThere are some common use-cases these days for site-specific control:
Today's SolutionsOften the solutions to this are one of the following:
Modeling solution after
|
I agree there's a need here.
The later two could possibly be done by an HTML attribute, some JS API, or some CSS property, but none of them exist. Even though we currently don't treat them as such, animated GIFs/APNG effectively are (muted) videos. They're just as much moving pictures as things that fit in the video element are. All the reasons for why it can be desirable to pause/resume videos are applicable to them as well. #1615 (comment) gives some reasonable use cases, Here are some more:
One answer might just be "don't use animated GIFs / APNGs, use actual video formats". However, even though the I am not 100% sure whether this is a CSS issue or an HTML one, but I'm going with CSS, as a CSS solution could be applicable to foreground and background images, in a way that an HTML one could not. My main point is not how it should be solved, but that it should be solved. Here's a straw-man variation on the earlier
|
As far as I know we still don't have any video formats that support lossless encoding or transparency, so there continues to be a need for GIF and WebP in order to deliver animation for this kind of content. |
Not if I have prefers-reduced-motion: reduce set. I don't want the animation until I click a play button. I constantly accidentally hover, even hover and pause, over content on my way to point at other content and having it trigger motion is distracting. Same with when I scroll past content on my way to other content. (Lest I create topic drift, this applies to pop-up menus as well.) I currently have my browser (Firefox) set to not play animated gifs at all, but I'd like the option to actively choose to play some of them when I'm good and ready. |
The suggested functionality does not mean that the browser itself couldn't also have the ability to suppress gif animations (or videos for that matter). The proposed control here would not forcibly make GIFs play when the user has, as you have, turn on some setting to disable animation. Browsers that want to offer this setting could absolutely continue to. The proposal here is the other way around: allow the author to pause (and resume) animated images that would otherwise play automatically. The browser doesn't know which GIFs are decorative bits whose animation can be suppressed outright when users when reduced motion, and which are content, which should remain viewable if desired (but maybe upon clicking some play button instead of on hover). So, as it is, if the browser forcibly suppresses animation of images, you will either no have means to individually turn them back on (as is case for Safari and Firefox), or have some UI element for every stopped GIF, even the decorative ones with superfluous animations that wouldn't need one. Besides, since the browser, not the author, inserts this UI element, there's no way for the author to control where it goes, and it might clash with the site's own UI. Say, for example, that a flashy/tacky website has pulsating / sparkling images used as buttons. It wouldn't be great if a GIF-stopping browser added play buttons on its own onto that site's GIF-based buttons, it's GIF-based checkboxes, etc. But if it doesn't, it also doesn't add them to videos-as-GIFs, since it doesn't know the difference.
The feature above could be leveraged to introduce something like that. In addition to the existing forcible and irreversible stop of all image animations, browsers could introduce (something like) |
I did not find an issue for the related situation where an author would want to mute a video or audio file that is playing. Can these be handled together or should a new issue be opened? Years ago, I already raised #5607 for discovering the respective (situational) user preference. |
It would be nice to have a CSS property for disabling image animation. Use cases include:
I'm imagining something like
elements and background-images.
image-animation: auto | none
, wherenone
would disable image animation onSemantics are slightly subtle to define, because HTML defines image animations as keyed by URL, instead of per element. I can think of two options:
drawImage
behaves)where the second seems tricker to implement (e.g., might include cloning SVG documents?) but also more useful than the first.
The text was updated successfully, but these errors were encountered: