Implement fuzzy page search using fuse.js (#86)

This commit is contained in:
Mungai Njoroge
2022-09-10 10:46:45 -04:00
committed by GitHub
parent befdf383b6
commit 5770a66d67
67 changed files with 568 additions and 558 deletions
+12
View File
@@ -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;
}
},