File tree Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 1
1
import './styles.css' ;
2
2
import LOGO from './assets/cd-labs-logo.png' ;
3
3
4
+ // --------------------------------------------------------------------------------
5
+
4
6
export function buildMainLogo ( ) {
5
7
const logoContainer = document . createElement ( 'div' ) ;
6
8
const logoImg = document . createElement ( 'img' ) ;
@@ -17,4 +19,17 @@ export function buildMainLogo() {
17
19
logoContainer . appendChild ( logoText ) ;
18
20
19
21
return logoContainer ;
22
+ }
23
+
24
+ // --------------------------------------------------------------------------------
25
+
26
+ export function changeLogoOnScroll ( ) {
27
+ const logoContainer = document . querySelector ( '.main-logo' ) as HTMLElement ;
28
+ if ( ! logoContainer ) return ;
29
+
30
+ if ( window . scrollY > 50 ) {
31
+ logoContainer . classList . add ( 'scrolled' ) ;
32
+ } else {
33
+ logoContainer . classList . remove ( 'scrolled' ) ;
34
+ }
20
35
}
Original file line number Diff line number Diff line change 1
-
2
1
.main-logo {
3
2
position : fixed;
4
3
top : 40px ;
5
4
left : 55px ;
5
+ transition : all 0.3s cubic-bezier (0.4 , 0 , 0.2 , 1 );
6
6
7
7
img {
8
8
width : 95px ;
9
9
height : 95px ;
10
10
image-rendering : pixelated;
11
+ transition : width 0.3s , height 0.3s ;
12
+ }
13
+
14
+ img : hover {
15
+ animation : rotate 0.5s steps (4 ) infinite;
11
16
}
12
17
13
18
p {
17
22
font-family : "Handjet" , sans-serif;
18
23
font-size : 2em ;
19
24
font-weight : 900 ;
25
+ transition : opacity 0.3s ;
20
26
}
21
- }
27
+ }
28
+
29
+ .main-logo .scrolled img {
30
+ width : 60px ;
31
+ height : 60px ;
32
+ }
33
+
34
+ .main-logo .scrolled p {
35
+ opacity : 0 ;
36
+ pointer-events : none;
37
+ }
38
+
39
+
40
+ @keyframes rotate {
41
+ 100% {
42
+ transform : rotate (360deg );
43
+ }
44
+ }
45
+
Original file line number Diff line number Diff line change 1
- import { buildMainLogo } from "./components/logo" ;
1
+ import { buildMainLogo , changeLogoOnScroll } from "./components/logo" ;
2
2
import { router } from "./core/router" ;
3
3
import { homeView , buildViewBase , renderView } from "./views" ;
4
4
import { buildTopNav } from "./components/top-nav" ;
@@ -20,6 +20,8 @@ function init() {
20
20
21
21
body . appendChild ( mainLogo ) ;
22
22
body . appendChild ( nav ) ;
23
+ window . addEventListener ( 'scroll' , changeLogoOnScroll ) ;
24
+
23
25
body . appendChild ( contentPage ) ;
24
26
25
27
You can’t perform that action at this time.
0 commit comments