Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vtbag/website. The @vtbag website. ⭐️ Please star to support this work! ⭐️
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109---
---
<!doctype html><html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width" /> <meta name="color-scheme" content="light dark" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <title>Grand Hotel</title> </head> <body> <button>Click</button> <div class="outer"> <div class="container"> <div id="ball"> <ul> <li>item 1</li> <li>item 2</li> </ul> </div> </div> </div> <script> const container = document.querySelector<HTMLElement>(".container")!; const outer = container?.parentElement!; const button = document.querySelector("button")!; button.addEventListener("click", (e) => { console.log("Button click"); e.preventDefault(); e.stopPropagation(); if (container.activeViewTransition) { document.head.insertAdjacentHTML( "beforeend", `<style id="temp-styles"> </style>`, ); outer.startViewTransition!(() => {}); } });
document.addEventListener("click", () => {
container.startViewTransition!(() => { container.setAttribute( "data-state", container.getAttribute("data-state") !== "2" ? "2" : "1", ); }).ready.then(()=>{ container.style.viewTransitionScope = "none"; container.insertAdjacentHTML("beforeend","<div class=new-element>New Element</div") const style = getComputedStyle(container); console.log(style.viewTransitionScope) outer.startViewTransition!(); }); }); </script> </body>
<style is:global> ::view-transition-group(*) { animation-duration: 5s; }
.outer, .container { contain: paint; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
.container { view-transition-name: none; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; min-height: 100vh; padding: 16px; gap: 12px; view-transition-scope: none !important; }
.new-element { view-transition-name: match-element; } #ball { view-transition-name: ball; width: 200px; height: 200px; border-radius: 50%; background-color: darkgreen; }
.container[data-state="2"] { align-items: flex-start; } </style></html>