Created
November 15, 2024 11:48
-
-
Save OnurGumus/bd7af8e564fd377738e46c3931a35b0c to your computer and use it in GitHub Desktop.
MPA View Transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" class="home"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>View Transitions</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover"> | |
<link rel="stylesheet" href="view-transitions.css"> | |
<script src="view-transitions.js"></script> | |
</head> | |
<body> | |
<main> | |
<div> | |
<h1 class="header-1">Page 1</h1> | |
<p> | |
<a href="view-transitions2.html">Page 2</a> | |
</p> | |
<p> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
</p> | |
<p> | |
<a href="view-transitions2.html">Page 2</a> | |
</p> | |
</div> | |
</main> | |
<footer> | |
<p> | |
This is the footer | |
</p> | |
</footer> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" class="home"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>View Transitions</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover"> | |
<link rel="stylesheet" href="view-transitions.css"> | |
<script src="view-transitions.js"></script> | |
</head> | |
<body> | |
<main> | |
<header> | |
<a class="back-link">< Back</a> | |
</header> | |
<div> | |
<h1 class="header-1 page-2">Page 1</h1> | |
<p> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
</p> | |
</div> | |
</main> | |
<footer> | |
<p> | |
This is the footer | |
</p> | |
</footer> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
--animation-duration: 300ms; | |
--animation-timing-function: cubic-bezier(0.465, 0.183, 0.153, 0.946); | |
} | |
@view-transition { | |
navigation: auto; | |
types: backnavigation, forwardnavigation; | |
} | |
html, body { | |
height: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
.header-1.page-2{ | |
zoom:0.5; | |
color:red; | |
} | |
.header-1{ | |
width: fit-content; | |
} | |
main { | |
contain: layout; | |
padding-bottom: 3rem; | |
} | |
h1 { | |
margin: 1rem; | |
} | |
p { | |
padding-inline: 1rem; | |
} | |
.home body { | |
background-color: white; | |
} | |
.next body { | |
background-color: #cccccc; | |
} | |
header { | |
display: flex; | |
align-items: center; | |
height: 80px; | |
background-color: #ff0000; | |
color: #ffffff; | |
padding-inline: 1rem; | |
font-size: 1.5rem; | |
} | |
footer { | |
view-transition-name: main-footer; | |
position: fixed; | |
left: 0; | |
bottom: 0; | |
background-color: #ffffff; | |
width: 100%; | |
} | |
@keyframes fade-in { | |
from { | |
opacity: 0; | |
} | |
to { | |
opacity: 1; | |
} | |
} | |
@keyframes fade-out { | |
from { | |
opacity: 1; | |
} | |
to { | |
opacity: 0; | |
} | |
} | |
@keyframes slide-out { | |
from { | |
transform: translateX(0); | |
} | |
to { | |
transform: translateX(-30%); | |
} | |
} | |
@keyframes slide-out-reverse { | |
from { | |
transform: translateX(-30%); | |
} | |
to { | |
transform: translateX(0); | |
} | |
} | |
@keyframes slide-in { | |
from { | |
transform: translateX(100%); | |
} | |
to { | |
transform: translateX(0); | |
} | |
} | |
@keyframes slide-in-reverse { | |
from { | |
transform: translateX(0); | |
} | |
to { | |
transform: translateX(100%); | |
} | |
} | |
::view-transition-new(root), | |
::view-transition-old(root) { | |
animation-duration: var(--animation-duration); | |
animation-timing-function: var(--animation-timing-function); | |
animation-direction: normal; | |
} | |
html:active-view-transition-type(forwardnavigation) { | |
&::view-transition-old(root) { | |
animation-name: slide-out; | |
} | |
&::view-transition-new(root) { | |
animation-name: slide-in; | |
mix-blend-mode: normal; | |
} | |
} | |
html:active-view-transition-type(backnavigation) { | |
&::view-transition-new(root) { | |
animation-name: slide-out-reverse; | |
} | |
&::view-transition-old(root) { | |
animation-name: slide-in-reverse; | |
mix-blend-mode: normal; | |
z-index: 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" class="home"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>View Transitions</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover"> | |
<link rel="stylesheet" href="view-transitions.css"> | |
<script src="view-transitions.js"></script> | |
</head> | |
<body> | |
<main> | |
<div> | |
<h1 class="header-1">Page 1</h1> | |
<p> | |
<a href="view-transitions2.html">Page 2</a> | |
</p> | |
<p> | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus, accusantium aperiam dolores harum non provident, quasi ratione sit sunt tempore, vero voluptas voluptate voluptatibus. Ab, alias distinctio. Nobis, nulla, repellat. | |
</p> | |
<p> | |
<a href="view-transitions2.html">Page 2</a> | |
</p> | |
</div> | |
</main> | |
<footer> | |
<p> | |
This is the footer | |
</p> | |
</footer> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment