-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cross-document view transitions demo
- Loading branch information
1 parent
929e396
commit 52ca0c6
Showing
18 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Cross-document view transition example: Page 1</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
<script defer src="index.js"></script> | ||
</head> | ||
|
||
<body> | ||
<p><a href="page2.html">Go to page 2</a></p> | ||
<img src="images/image1.jpg" alt="A suspension bridge spanning a river, with a cityscape on the other side."> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
console.log("script loaded"); | ||
|
||
window.addEventListener("pageswap", event => { | ||
console.log("pageswap fired"); | ||
// event.viewTransition.skipTransition(); | ||
}); | ||
|
||
|
||
window.addEventListener("pagereveal", event => { | ||
console.log("pagereveal fired"); | ||
// event.viewTransition.skipTransition(); | ||
}); | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Cross-document view transition example: Page 2</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
<script defer src="index.js"></script> | ||
</head> | ||
|
||
<body> | ||
<p><a href="index.html">Go back to page 1</a></p> | ||
<img src="images/image2.jpg" alt="A large green tropical leaf in the middle of a jungle."> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Example layout */ | ||
|
||
html { | ||
font-family: Arial, Helvetica, sans-serif; | ||
height: 100%; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
height: inherit; | ||
} | ||
|
||
img { | ||
width: 100vw; | ||
height: 100vh; | ||
object-fit: cover; | ||
} | ||
|
||
p { | ||
position: absolute; | ||
top: 20px; | ||
left: 20px; | ||
font-size: 2rem; | ||
padding: 20px; | ||
margin: 0; | ||
border-radius: 5px; | ||
background-color: rgba(255 255 255 / 0.8); | ||
} | ||
|
||
/* Turn cross-document view-transitions on */ | ||
/* Note that this at-rule is all that is needed to create the default cross-fade animation */ | ||
|
||
@view-transition { | ||
navigation: auto; | ||
} | ||
|
||
/* Customize the default animation */ | ||
|
||
/* ::view-transition-old(root), | ||
::view-transition-new(root) { | ||
animation-duration: 0.5s; | ||
} */ | ||
|
||
/* create a new animation */ | ||
|
||
@keyframes move-out { | ||
from { | ||
transform: translateY(0%); | ||
} | ||
|
||
to { | ||
transform: translateY(-100%); | ||
} | ||
} | ||
|
||
@keyframes move-in { | ||
from { | ||
transform: translateY(100%); | ||
} | ||
|
||
to { | ||
transform: translateY(0%); | ||
} | ||
} | ||
|
||
::view-transition-old(root) { | ||
animation: 0.4s ease-in both move-out; | ||
|
||
} | ||
|
||
::view-transition-new(root) { | ||
animation: 0.4s ease-in both move-in; | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.