Created
June 5, 2023 11:21
-
-
Save noamr/b82f772ab6b4c6f234af0db21370b4c6 to your computer and use it in GitHub Desktop.
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> | |
<head> | |
<meta name="view-transition" content="same-origin"> | |
</head> | |
<body> | |
<style> | |
h1 { | |
view-transition-name: hero; | |
} | |
html[data-clicked] h1 { | |
view-transition-name: none; | |
} | |
a { | |
display: block; | |
} | |
::view-transition { | |
opacity: .5; | |
} | |
</style> | |
<script> | |
document.addEventListener("click", ({target}) => { | |
if (target.classList.contains("hero-link")) | |
target.style.viewTransitionName = "hero"; | |
document.documentElement.dataset.clicked = true; | |
}, {capture: true}) | |
</script> | |
<nav> | |
<a class="hero-link" href="?page=about">About</a> | |
<a class="hero-link" href="?page=contact">Contact</a> | |
</nav> | |
<h1><script>document.write(new URL(location.href).searchParams.get("page") || "home")</script></h1> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment