added view transition for smoother theme toggle
This commit is contained in:
parent
30bf7add5f
commit
0f7e96328f
11
components/dist/theme-toggle.js
vendored
11
components/dist/theme-toggle.js
vendored
@ -102,8 +102,15 @@ class ThemeToggle extends HTMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleState() {
|
toggleState() {
|
||||||
this.toggleAttribute('checked');
|
if (!document.startViewTransition) {
|
||||||
this.fireEvent();
|
this.toggleAttribute('checked');
|
||||||
|
this.fireEvent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.startViewTransition(() => {
|
||||||
|
this.toggleAttribute('checked');
|
||||||
|
this.fireEvent();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
handleKeyDown(e) {
|
handleKeyDown(e) {
|
||||||
if (e.key === ' ') {
|
if (e.key === ' ') {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user