File tree Expand file tree Collapse file tree 4 files changed +35
-6
lines changed Expand file tree Collapse file tree 4 files changed +35
-6
lines changed Original file line number Diff line number Diff line change 15
15
{% include head--icons.html %}
16
16
17
17
< script >
18
- // when the whole document has loaded, add a CSS class
18
+
19
+ // global vars
20
+ var today = new Date ( ) ;
21
+ var tomorrow = new Date ( ) ;
22
+ tomorrow . setDate ( tomorrow . getDate ( ) + 1 ) ;
23
+ var playLogo = false ;
24
+
25
+ // if we have localstorage,
26
+ // see if the logo_expiry has happened or not
27
+ if ( window . localStorage ) {
28
+ var expires = new Date ( localStorage . getItem ( 'logo_expiry' ) ) ;
29
+ playLogo = ( today - expires > 0 ) ;
30
+ }
31
+
32
+ // if the logo animation has been played already, just load the content
19
33
window . onload = function ( ) {
20
- var body = document . getElementsByTagName ( 'body' ) [ 0 ]
21
- if ( body . className . indexOf ( 'home' ) == - 1 ) {
34
+ var body = document . getElementsByTagName ( 'body' ) [ 0 ] ;
35
+ if ( ! playLogo || body . className . indexOf ( 'home' ) < 0 ) {
22
36
body . className += ' loaded' ;
23
37
}
24
38
} ;
Original file line number Diff line number Diff line change 1
1
< script >
2
+ var body = document . getElementsByTagName ( 'body' ) [ 0 ] ;
3
+
2
4
// we add this inline to let the CSS know we have JS capability
3
5
// as soon as humanly possible.
4
- document . getElementsByTagName ( 'body' ) [ 0 ] . className += ' js' ;
6
+ body . className += ' js' ;
7
+
8
+ // if our logo animation hasn't been played in 24 hours,
9
+ // clear the localstorage ready to play it (next code block)
10
+ if ( playLogo ) {
11
+ localStorage . removeItem ( 'logo_expiry' ) ;
12
+ }
13
+
14
+ // if we're on the homepage, and the logo animation hasn't played before
15
+ // add an "animate" css class and set the localstorage item
16
+ if ( body . className . indexOf ( 'home' ) > - 1 && playLogo && window . localStorage ) {
17
+ body . className += ' animate-logo' ;
18
+ localStorage . setItem ( "logo_expiry" , tomorrow ) ;
19
+ }
5
20
</ script >
6
21
7
22
< header class ="site-header ">
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ svg { display:block; margin: 0 auto; width: 280px; max-width: 80vw; }
16
16
17
17
#logomark path { fill : $brand-color ; }
18
18
19
- .home {
19
+ .home.animate-logo {
20
20
21
21
svg {
22
22
width : 100% ;
Original file line number Diff line number Diff line change 70
70
/* *
71
71
* homepage content animation
72
72
*/
73
- .home {
73
+ .home.animate-logo {
74
74
.page-content {
75
75
animation : movein 1.5s ease-out forwards 4s ;
76
76
opacity : 0 ;
You can’t perform that action at this time.
0 commit comments