Remove flash on loading template pictures

This commit is contained in:
Andrew Kingston 2022-04-01 18:16:13 +01:00
parent 0037a6f737
commit 9ad826ffde
1 changed files with 5 additions and 12 deletions

View File

@ -6,15 +6,10 @@
export let overlayEnabled = true export let overlayEnabled = true
let imageError = false let imageError = false
let imageLoaded = false
const imageRenderError = () => { const imageRenderError = () => {
imageError = true imageError = true
} }
const imageLoadSuccess = () => {
imageLoaded = true
}
</script> </script>
<div class="template-card" style="background-color:{backgroundColour};"> <div class="template-card" style="background-color:{backgroundColour};">
@ -23,8 +18,7 @@
alt={name} alt={name}
src={imageSrc} src={imageSrc}
on:error={imageRenderError} on:error={imageRenderError}
on:load={imageLoadSuccess} class:error={imageError}
class={`${imageLoaded ? "loaded" : ""}`}
/> />
<div style={`display:${imageError ? "block" : "none"}`}> <div style={`display:${imageError ? "block" : "none"}`}>
<svg <svg
@ -104,15 +98,14 @@
width: 100%; width: 100%;
} }
.template-card img.loaded {
display: block;
}
.template-card img { .template-card img {
display: none; display: block;
max-width: 100%; max-width: 100%;
border-radius: var(--border-radius-s) 0px var(--border-radius-s) 0px; border-radius: var(--border-radius-s) 0px var(--border-radius-s) 0px;
} }
.template-card img.error {
display: none;
}
.template-card:hover { .template-card:hover {
background: var(--spectrum-alias-background-color-tertiary); background: var(--spectrum-alias-background-color-tertiary);