A Pen by Michael Gehrmann on CodePen.
Created
February 13, 2026 02:09
-
-
Save kazzohikaru/f215e7057d688183ebbaf07af5836461 to your computer and use it in GitHub Desktop.
View Transition digit
This file contains hidden or 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
| <div class="integer"> | |
| 1 | |
| </div> |
This file contains hidden or 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
| let counter = 1; | |
| let el = document.querySelector(".integer") | |
| setInterval(()=>{ | |
| counter = counter < 10 ? counter + 1 : 0; | |
| const transition = document.startViewTransition(() => { | |
| el.textContent = counter; | |
| }); | |
| },1000); |
This file contains hidden or 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
| @view-transition { | |
| navigation: auto; | |
| } | |
| @keyframes body-animation { | |
| 0% { | |
| background-position: 0 0; | |
| } | |
| 100% { | |
| background-position: 0 100vh; | |
| } | |
| } | |
| html { | |
| min-block-size: 100%; | |
| display: grid; | |
| place-items: center; | |
| background-image: linear-gradient(hotpink, deeppink,hotpink); | |
| animation: body-animation 3s linear infinite ; | |
| } | |
| .integer { | |
| padding: 0.5em; | |
| min-width: 2ch; | |
| text-align: center; | |
| font-size: 25vmin; | |
| font-weight: bold; | |
| background-color: deeppink; | |
| color: white; | |
| border-radius: 0.3em; | |
| view-transition-name: number; | |
| border: 2px solid #fff3; | |
| } | |
| ::view-transition-group(root) { | |
| } | |
| ::view-transition-group(number) { | |
| animation-duration: 1s; | |
| } | |
| @keyframes blink { | |
| 0% { | |
| clip-path: inset(0 0% 100% 0); | |
| filter: brightness(1.3); | |
| opacity: 1; | |
| rotate: x -90deg; | |
| } | |
| 100% { | |
| clip-path: inset(0 0% 0 0); | |
| filter: brightness(1); | |
| opacity: 1; | |
| } | |
| } | |
| @keyframes whipe { | |
| 0% { | |
| clip-path: inset(0 0% 0 0); | |
| filter: brightness(1); | |
| } | |
| 100% { | |
| clip-path: inset(100% 0% 0 0); | |
| filter: brightness(0.9); | |
| } | |
| } | |
| @keyframes turn{ | |
| 0%{ | |
| rotate: x -40deg | |
| } | |
| 100%{ | |
| rotate: x 0deg | |
| } | |
| } | |
| ::view-transition-image-pair(number) { | |
| transform-style: preserve-3d; | |
| } | |
| ::view-transition-new(number) { | |
| opacity: 1; | |
| animation-name: blink; | |
| z-index: 1; | |
| } | |
| ::view-transition-old(number) { | |
| opacity: 1; | |
| clip-path: inset(0 50% 0 0); | |
| z-index: 2; | |
| animation-name: whipe; | |
| transform-origin: 50% 50%; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment