From 64027a74f9a15d21d6903cb229353bb0185e3a32 Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Mon, 4 Jan 2021 16:57:52 -0500 Subject: attempted to speed up search with typing delay --- iridescence/src/components/Navbar.vue | 3 +++ iridescence/src/components/ProductSearch.vue | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/iridescence/src/components/Navbar.vue b/iridescence/src/components/Navbar.vue index 6b9f609..3a3390c 100644 --- a/iridescence/src/components/Navbar.vue +++ b/iridescence/src/components/Navbar.vue @@ -21,6 +21,9 @@ F.A.Q. + + About Us + Care & Handling diff --git a/iridescence/src/components/ProductSearch.vue b/iridescence/src/components/ProductSearch.vue index d492b66..f60931c 100644 --- a/iridescence/src/components/ProductSearch.vue +++ b/iridescence/src/components/ProductSearch.vue @@ -45,6 +45,7 @@ export default { data() { return { term: "", + searchTimer: function() {}, sortOptions: { "Featured Items": a => (a.featured ? -1 : 1), "In Stock": (a, b) => a.quantity < b.quantity, @@ -72,7 +73,10 @@ export default { }, methods: { updateSearch() { - this.$store.commit("searchTerm", this.term); + clearTimeout(this.searchTimer); + this.timeout = setTimeout(() => { + this.$store.commit("searchTerm", this.term); + }, 1000); }, updateSort() { this.$store.commit("compare", this.sortOptions[this.sortOptionName]); @@ -80,3 +84,5 @@ export default { } }; + + -- cgit v1.2.3