view transition for javascript
This commit is contained in:
parent
9dcb01b2ae
commit
80b2e2e5b2
1 changed files with 10 additions and 2 deletions
|
|
@ -78,8 +78,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
function toggleTheme(e) {
|
function toggleTheme_() {
|
||||||
e.preventDefault();
|
|
||||||
fetch('./light-dark-toggle?ref=https%3A%2F%2Fpagwin.xyz%2Fstatic%2Fdemos%2Flight-dark-demo-4%2F')
|
fetch('./light-dark-toggle?ref=https%3A%2F%2Fpagwin.xyz%2Fstatic%2Fdemos%2Flight-dark-demo-4%2F')
|
||||||
if (!document.body.classList.contains("toggled")) {
|
if (!document.body.classList.contains("toggled")) {
|
||||||
document.body.classList.add("toggled")
|
document.body.classList.add("toggled")
|
||||||
|
|
@ -88,6 +87,15 @@
|
||||||
document.body.classList.remove("toggled")
|
document.body.classList.remove("toggled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function toggleTheme(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (document.startViewTransition) {
|
||||||
|
document.startViewTransition(toggleTheme_);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
toggleTheme_();
|
||||||
|
}
|
||||||
|
}
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", () => {
|
||||||
document
|
document
|
||||||
.getElementById("full-demo")
|
.getElementById("full-demo")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue