-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Modal incompatible with native lazy loading #55
Comments
Hi @Wardojack , thank you for your feedback. You're absolutely right about why visibility is used in this case. Using When you want to animate the appearance/disappearance of a modal, you need the element to remain in the document flow during the transition. This is why Your solution of combining For cases where both performance and animations are needed, a common approach is using a combination of techniques - |
Since 2024 it's possible to transition from |
I'm developing a UI without using JS, hence my use of this library. My page was taking a long time to load due to an abundance of high-res images, so I decided to instead display scaled down thumbnails. I wanted to have the thumbnail trigger a modal which shows the full size image, but without having to download all the images at once. I added
loading="lazy"
to my images, but as the modal is only hidden byvisibility="hidden"
and still exists in the document flow, the browser still considers it to be in the viewport and loads all my images at once.I fixed this issue by adding
display="none"
to[data-modal]
's default state, anddisplay="flex"
under the[data-modal]:target
selector.I assume that this scenario has just not been considered because, let's be real, who is actually this averse to using a little bit of JS in their project?
Is there another reason that visibility was used, or am I on the money here?
The text was updated successfully, but these errors were encountered: