Render header photo in place details

Shows the blurhash and fades in the image once downloaded
This commit is contained in:
2026-04-21 23:07:06 +04:00
parent 99cfd96ca1
commit 85a8699b78
6 changed files with 189 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
import { modifier } from 'ember-modifier';
export default modifier((element, [url]) => {
if (!url) return;
// Remove classes when URL changes
element.classList.remove('loaded');
element.classList.remove('loaded-instant');
// Create an off-DOM image to reliably check cache status
// without waiting for the actual DOM element to load it
const img = new Image();
img.src = url;
if (img.complete) {
// Already in browser cache, skip the animation
element.classList.add('loaded-instant');
return;
}
const handleLoad = () => {
element.classList.add('loaded');
};
element.addEventListener('load', handleLoad);
return () => {
element.removeEventListener('load', handleLoad);
};
});