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>
|
||||
<script type="module">
|
||||
function toggleTheme(e) {
|
||||
e.preventDefault();
|
||||
function toggleTheme_() {
|
||||
fetch('./light-dark-toggle?ref=https%3A%2F%2Fpagwin.xyz%2Fstatic%2Fdemos%2Flight-dark-demo-4%2F')
|
||||
if (!document.body.classList.contains("toggled")) {
|
||||
document.body.classList.add("toggled")
|
||||
|
|
@ -88,6 +87,15 @@
|
|||
document.body.classList.remove("toggled")
|
||||
}
|
||||
}
|
||||
function toggleTheme(e) {
|
||||
e.preventDefault();
|
||||
if (document.startViewTransition) {
|
||||
document.startViewTransition(toggleTheme_);
|
||||
}
|
||||
else {
|
||||
toggleTheme_();
|
||||
}
|
||||
}
|
||||
window.addEventListener("load", () => {
|
||||
document
|
||||
.getElementById("full-demo")
|
||||
|
|
|
|||
Loading…
Reference in a new issue