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() {
|
||||
this.toggleAttribute('checked');
|
||||
this.fireEvent();
|
||||
if (!document.startViewTransition) {
|
||||
this.toggleAttribute('checked');
|
||||
this.fireEvent();
|
||||
return;
|
||||
}
|
||||
document.startViewTransition(() => {
|
||||
this.toggleAttribute('checked');
|
||||
this.fireEvent();
|
||||
});
|
||||
}
|
||||
handleKeyDown(e) {
|
||||
if (e.key === ' ') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user