Skip to content
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

AccessKit Disable GIFs: Remove white background workaround #1681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcustyphoon
Copy link
Collaborator

@marcustyphoon marcustyphoon commented Jan 4, 2025

Description

We currently have a workaround for "pausing" certain GIF elements (the ones which use CSS background-image) where we simply replace the GIF with a white background instead of properly freezing them until they're hovered. It dawned on me, however, that there is a way to pause these properly: a CSS property override replacing the gif URL with a blob URL, which we can generate from a canvas element.

This implements this. Functionality-wise, it seems to work quite well. Unfortunately, this relies on quite a bit of inelegant string parsing; I assume the regex I wrote can be cleaned up a little bit, but it's still fundamentally quite complex and I don't know of a better way to parse the url out of e.g. background-image:linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8)), url("https://64.media.tumblr.com/e6ca525d90692476df81e72bdd9cdfe5/539b205af19f15b8-ec/s400x600/a1c55d65fb3374ae5945af2a6ec16d429842cacc.gifv").

So it's quite cool that it works, but... yeah, I dunno.

Aside: can you use CSS to effectively replace the contents of an <img> element? If so, this method could theoretically replace the entire feature and allow for pausing a whole bunch of random elements we currently don't hit (blog header images, search result thumbnails), which would be kind of wild. I think you might be able to?

Testing steps

Confirm that the gifs in the right column of the tagged page (e.g. https://www.tumblr.com/tagged/gif) are paused correctly and become unpaused when hovered.

@marcustyphoon marcustyphoon force-pushed the disable-gifs-pause-background branch from d40a99e to 11f4a10 Compare January 4, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant