This repository was archived by the owner on Mar 9, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,13 @@ export default class JehonImageLoading extends HTMLElement {
62
62
63
63
opacity: 1;
64
64
transition: opacity ${ JehonImageLoading . #transitionTimeMs} ms linear;
65
+ }
66
+
67
+ img[legacy] {
68
+ opacity: 0;
69
+ /* Removing the image is done a bit later to avoid the 'black' passage */
70
+ transition-delay: ${ JehonImageLoading . #transitionTimeMs / 2 } ms
71
+ }
65
72
66
73
img[loading] {
67
74
opacity: 0;
@@ -120,12 +127,14 @@ export default class JehonImageLoading extends HTMLElement {
120
127
}
121
128
122
129
// Image is really ready
130
+ this . shadowRoot . querySelectorAll ( 'img:not([loading])' )
131
+ . forEach ( img => img . setAttribute ( 'legacy' , 'legacy' ) ) ;
123
132
el . removeAttribute ( 'loading' ) ;
124
133
125
134
// Wait for animation to end
126
135
await sleep ( 2 * Math . max ( JehonImageLoading . #transitionTimeMs, 1 ) ) ;
127
136
128
- this . shadowRoot . querySelectorAll ( 'img:not([loading]):not(:last-of-type) ' )
137
+ this . shadowRoot . querySelectorAll ( 'img[legacy] ' )
129
138
. forEach ( img => img . remove ( ) ) ;
130
139
131
140
// Warn the parents
You can’t perform that action at this time.
0 commit comments