Skip to content

Commit b361ff4

Browse files
committed
Updated for codepen
1 parent 273a234 commit b361ff4

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

src/pages/basics/_pseudo.astro

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
<button>Click</button>
1616
<div class="outer">
1717
<div class="container">
18-
<div
19-
id="ball"
20-
style="view-transition-name: ball; width:200px; height: 200px;border-radius: 50%; background-color: darkgreen"
21-
>
18+
<div id="ball">
2219
<ul>
2320
<li>item 1</li>
2421
<li>item 2</li>
@@ -46,13 +43,18 @@
4643
});
4744

4845
document.addEventListener("click", () => {
49-
console.log("state change");
5046

5147
container.startViewTransition!(() => {
52-
const state = container.getAttribute("data-state");
53-
container.style.alignItems =
54-
state !== "2" ? "flex-start" : "flex-end";
55-
container.setAttribute("data-state", state !== "2" ? "2" : "1");
48+
container.setAttribute(
49+
"data-state",
50+
container.getAttribute("data-state") !== "2" ? "2" : "1",
51+
);
52+
}).ready.then(()=>{
53+
container.style.viewTransitionScope = "none";
54+
container.insertAdjacentHTML("beforeend","<div class=new-element>New Element</div")
55+
const style = getComputedStyle(container);
56+
console.log(style.viewTransitionScope)
57+
outer.startViewTransition!();
5658
});
5759
});
5860
</script>
@@ -77,24 +79,30 @@
7779
}
7880

7981
.container {
82+
view-transition-name: none;
8083
display: flex;
8184
flex-direction: column;
8285
align-items: flex-end;
8386
justify-content: center;
8487
min-height: 100vh;
8588
padding: 16px;
8689
gap: 12px;
90+
view-transition-scope: none !important;
8791
}
8892

89-
::view-transition-group(ball) {
93+
.new-element {
94+
view-transition-name: match-element;
95+
}
96+
#ball {
9097
view-transition-name: ball;
98+
width: 200px;
99+
height: 200px;
100+
border-radius: 50%;
101+
background-color: darkgreen;
91102
}
92-
.container {
93-
view-transition-name: none;
94-
view-transition-scope: none !important;
95-
&::view-transition-group(ball) {
96-
view-transition-scope: none !important;
97-
}
103+
104+
.container[data-state="2"] {
105+
align-items: flex-start;
98106
}
99107
</style>
100108
</html>

0 commit comments

Comments
 (0)