Fade in image embeds on load - #52
Open
sietsev-q42 wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restores a fade-in effect for DOM-based image embeds by hiding embed <img> elements until they have finished loading, then revealing them via a CSS transition controlled by custom properties.
Changes:
- Added global CSS custom properties and opacity/transition rules to fade in embed images once
data-loadedis present. - Added an image
loadevent handler in the DOM embed path to setdata-loadedon the embed<img>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/embed/image-embeds.css | Adds fade-in styling for embed images using opacity + transition and custom properties. |
| src/embed/embed.ts | Adds a load handler on DOM embed <img> creation to set data-loaded. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+236
to
+240
| events: { | ||
| load: (e: Event) => { | ||
| const img = e.target as HTMLImageElement; | ||
| img.setAttribute("data-loaded", ""); | ||
| }, |
Comment on lines
+10
to
+17
| micrio-image-embeds img { | ||
| opacity: 0; | ||
| transition: opacity var(--micrio-embed-fade-in-duration) var(--micrio-embed-fade-in-ease); | ||
| } | ||
|
|
||
| micrio-image-embeds img[data-loaded] { | ||
| opacity: 1; | ||
| } |
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.
This PR is initially a conversation starter.
I believe embeds used to fade in with older Micrio versions. This is not the case in v7 and at least not since 5.4.28.
This PR applies the fade in only to the DOM version of an image embed by adding a load event listener and setting data-loaded on the image on the callback.
The "animation" is done in css and configurable with custom properties.