Skip to content

Commit

Permalink
Add view transition
Browse files Browse the repository at this point in the history
  • Loading branch information
pepelsbey committed Feb 14, 2023
1 parent 5f7f421 commit 4b7aa31
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/layouts/page.njk
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<title>{{ title }}</title>

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

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

Expand Down
2 changes: 2 additions & 0 deletions src/styles/blocks/header/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
top: 0;
z-index: 2;
background-color: var(--color-back-primary);
view-transition-name: header;
contain: layout;
}

/* Link */
Expand Down
37 changes: 37 additions & 0 deletions src/styles/global/transitions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@keyframes fade-in {
from {
opacity: 0;
}
}

@keyframes fade-out {
to {
opacity: 0;
}
}

@keyframes slide-from-right {
from {
transform: translateX(30px);
}
}

@keyframes slide-to-left {
to {
transform: translateX(-30px);
}
}

::view-transition-old(root) {
animation:
90ms cubic-bezier(0.4, 0, 1, 1) both fade-out,
300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-to-left
;
}

::view-transition-new(root) {
animation:
210ms cubic-bezier(0, 0, 0.2, 1) 90ms both fade-in,
300ms cubic-bezier(0.4, 0, 0.2, 1) both slide-from-right
;
}
1 change: 1 addition & 0 deletions src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@import 'global/fonts.css';
@import 'global/box-model.css';
@import 'global/focus.css';
@import 'global/transitions.css';

/* Colors */

Expand Down

0 comments on commit 4b7aa31

Please sign in to comment.