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