feat(AccessKit): Re-implement download-GIF-on-hover feature - #2271
Draft
marcustyphoon wants to merge 3 commits into
Draft
feat(AccessKit): Re-implement download-GIF-on-hover feature#2271marcustyphoon wants to merge 3 commits into
marcustyphoon wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bit of an experiment. Kind of surprised this appears to (maybe?) work, though in writing up the technique it seems rather obvious in retrospect.
Implemented in #1853, the "Download paused GIFs: when hovered" feature of AccessKit Disable GIFs made use of a Tumblr layout with both a "poster" stationary image element and an animated image element. It overrode the poster to be visible and the animated image element to be
display: nonewhen the user was not hovering over the GIF, and because Tumblr setsloading="lazy"on the animated image*, the browser did not download it eagerly.As noted in #2243, this doesn't work anymore, since Tumblr now uses a single image element, swapping the source out for a poster version in some circumstances (media autoplay disabled; image element offscreen—I don't know why the latter condition, but I digress). Disable GIFs still works, using its good old fashioned code path of rendering the GIF onto a canvas element to make a "poster".
This PR attempts to bring back the behavior by setting the animated image element to
display: nonewhen not hovered, as before, and by grabbing the poster source URL from the react data and feeding it to our canvas-making code. Note that:.${canvasClass}${parentHovered}:not(:has(~ ${keyToCss('loader')} > ${keyToCss('knightRiderLoader')}))is a fix for this (showing the canvas during the load). Hopefully there's a more elegant solution to this.Not currently working with media autoplay disabled (#2270 clicks the images when they're first processed, which downloads the animated versions; this seems like it will be annoying to fix).
Oh, also, I have no idea if "the last image in the
posterImagesarray" is actually the right source to pick. Realistically, if we were confident about mirroring Tumblr's processing, "display: noneall of Tumblr's elements, grab the paused and animated source values from react data, and make two of our own image elements" would be a quite elegant solution that doesn't care about the media autoplay setting at all. Am I confident about that? Well... no.*unless you're in blog view; I don't know why
Screenshots
tba
Testing steps
tba