fix: add debounce to theme toggle to prevent flash-back
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const Theme = {
|
||||
_current: 'dark',
|
||||
_toggling: false,
|
||||
|
||||
init() {
|
||||
this._current = localStorage.getItem('turbosu-theme') || 'dark';
|
||||
@@ -7,8 +8,11 @@ const Theme = {
|
||||
},
|
||||
|
||||
toggle() {
|
||||
if (this._toggling) return;
|
||||
this._toggling = true;
|
||||
this._current = this._current === 'dark' ? 'light' : 'dark';
|
||||
this.apply();
|
||||
setTimeout(() => { this._toggling = false; }, 200);
|
||||
},
|
||||
|
||||
apply() {
|
||||
|
||||
Reference in New Issue
Block a user