forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Image block: Lightbox animation improvements (WordPress#51721)
* Add logic to use low-res image while high-res one is loading We need to have two <img> elements in the DOM inside the lightbox because otherwise the image flickers when we change the src. I removed the src and srcset attributes from the responsive image when the larger one is loaded to signal that the low-res one is no longer in use. * Add logic to preload image on hover * Update tests * PHP format * Prevent responsive images from being loaded unnecessarily The src attribute on the img elements was causing the srcset attribute to be added as well before the Interactivity API could remove them, causing images to be loaded before they were needed and in the wrong size. This commit removes the src attribute from the img elements before they are output to the DOM, and also updates the tests. * Prevent warning of undefined variable * Prevent warning of undefined variable - refactored * Replace getimagesize() with wp_getimagesize() * Resolve image flash when opening lightbox Rather than allowing the browser to pick the lightbox's responsive image, we now explicitly read the currentSrc attribute from the reference image and also prevent users from opening the lightbox until the reference image is fully loaded. Doing this, we can ensure the zoom animation plays smoothly and there are no oddities in the UX. --------- Co-authored-by: Carlos Bravo <carlos.bravo@automattic.com>
- Loading branch information
1 parent
ae4dd16
commit 7a04f44
Showing
3 changed files
with
131 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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