File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,15 @@ document.addEventListener('DOMContentLoaded', () => {
18
18
timeouts . push ( setTimeout ( animateStep , timeout ) ) ;
19
19
}
20
20
21
- timeouts . push (
22
- setTimeout ( ( ) => {
23
- logo . classList . remove ( 'init' ) ;
24
- animateStep ( ) ;
25
- } , 2000 )
26
- ) ;
21
+ // only start the animation if the document is visible on load
22
+ if ( ! document . hidden ) {
23
+ timeouts . push (
24
+ setTimeout ( ( ) => {
25
+ logo . classList . remove ( 'init' ) ;
26
+ animateStep ( ) ;
27
+ } , 2000 )
28
+ ) ;
29
+ }
27
30
28
31
// https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
29
32
document . addEventListener (
@@ -36,6 +39,7 @@ document.addEventListener('DOMContentLoaded', () => {
36
39
// clear the timeouts array
37
40
timeouts . length = 0 ;
38
41
} else {
42
+ // restart the animation when visible
39
43
animateStep ( ) ;
40
44
}
41
45
} ,
You can’t perform that action at this time.
0 commit comments