Skip to content

Commit 4b7aa31

Browse files
committed
Add view transition
1 parent 5f7f421 commit 4b7aa31

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

src/layouts/page.njk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<title>{{ title }}</title>
2828

2929
<meta name="viewport" content="width=device-width, initial-scale=1">
30+
<meta name="view-transition" content="same-origin">
3031

3132
<link rel="stylesheet" href="/styles/index.css">
3233

src/styles/blocks/header/base.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
top: 0;
66
z-index: 2;
77
background-color: var(--color-back-primary);
8+
view-transition-name: header;
9+
contain: layout;
810
}
911

1012
/* Link */

src/styles/global/transitions.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@keyframes fade-in {
2+
from {
3+
opacity: 0;
4+
}
5+
}
6+
7+
@keyframes fade-out {
8+
to {
9+
opacity: 0;
10+
}
11+
}
12+
13+
@keyframes slide-from-right {
14+
from {
15+
transform: translateX(30px);
16+
}
17+
}
18+
19+
@keyframes slide-to-left {
20+
to {
21+
transform: translateX(-30px);
22+
}
23+
}
24+
25+
::view-transition-old(root) {
26+
animation:
27+
90ms cubic-bezier(0.4, 0, 1, 1) both fade-out,
28+
300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left
29+
;
30+
}
31+
32+
::view-transition-new(root) {
33+
animation:
34+
210ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,
35+
300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right
36+
;
37+
}

src/styles/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import 'global/fonts.css';
44
@import 'global/box-model.css';
55
@import 'global/focus.css';
6+
@import 'global/transitions.css';
67

78
/* Colors */
89

0 commit comments

Comments
 (0)