mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 13:03:02 +00:00
Implement fuzzy page search using fuse.js (#86)
This commit is contained in:
@@ -4,20 +4,32 @@ export default defineStore("Loader", {
|
||||
state: () => ({
|
||||
loading: false,
|
||||
duration: 0,
|
||||
page: <HTMLHtmlElement | null>null,
|
||||
}),
|
||||
actions: {
|
||||
startLoading() {
|
||||
this.loading = true;
|
||||
this.duration = new Date().getTime();
|
||||
|
||||
if (!this.page) {
|
||||
this.page = document.getElementsByTagName("html")[0] as HTMLHtmlElement;
|
||||
}
|
||||
|
||||
this.page.classList.add("loading");
|
||||
},
|
||||
stopLoading() {
|
||||
const diff = new Date().getTime() - this.duration;
|
||||
const resetCursor = () => {
|
||||
this.page ? this.page.classList.remove("loading") : null;
|
||||
};
|
||||
|
||||
if (diff <= 250) {
|
||||
setTimeout(() => {
|
||||
resetCursor();
|
||||
this.loading = false;
|
||||
}, 250 - diff);
|
||||
} else {
|
||||
resetCursor();
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user