Skip to content

Commit

Permalink
feat(story): Adding throbber when loading full size image
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Dec 27, 2022
1 parent f20498f commit ef77eab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cmd/fibr/static/scripts/async-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ async function fetchThumbnail() {
}

const lazyImage = entry.target;
const parent = lazyImage.parentElement.parentElement;

const storyThrobber = generateThrobber([
'throbber-white',
'throbber-overlay',
]);
parent.appendChild(storyThrobber);

lazyImage.addEventListener(
'load',
() => parent.removeChild(storyThrobber),
{ once: true },
);

if (window.webpHero) {
const response = await fetch(lazyImage.dataset.src, {
credentials: 'same-origin',
Expand Down
Loading

0 comments on commit ef77eab

Please sign in to comment.