From 5265ceb803ae068e2d0e9a5ad322e5e51c40c629 Mon Sep 17 00:00:00 2001 From: liuzhanghao <3443718488@qq.com> Date: Fri, 14 Oct 2022 18:11:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=8D=B8=E8=BD=BD=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E6=8A=8A=E7=9B=B8=E5=85=B3=E4=BA=8B=E4=BB=B6=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Edit/components/Navigator.vue | 28 ++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/web/src/pages/Edit/components/Navigator.vue b/web/src/pages/Edit/components/Navigator.vue index 5d0ce644..96bde5c6 100644 --- a/web/src/pages/Edit/components/Navigator.vue +++ b/web/src/pages/Edit/components/Navigator.vue @@ -45,16 +45,28 @@ export default { }; }, mounted() { - this.$bus.$on("toggle_mini_map", (show) => { + this.$bus.$on("toggle_mini_map", this.toggle_mini_map); + this.$bus.$on("data_change", this.data_change); + this.$bus.$on("view_data_change", this.view_data_change); + }, + destroyed() { + this.$bus.$off("toggle_mini_map", this.toggle_mini_map); + this.$bus.$off("data_change", this.data_change); + this.$bus.$off("view_data_change", this.view_data_change); + }, + methods: { + toggle_mini_map(show) { this.showMiniMap = show; this.$nextTick(() => { - if (show) { + if (this.$refs.navigatorBox) { this.init(); + } + if (this.$refs.svgBox) { this.drawMiniMap(); } }); - }); - this.$bus.$on("data_change", () => { + }, + data_change() { if (!this.showMiniMap) { return; } @@ -62,8 +74,8 @@ export default { this.timer = setTimeout(() => { this.drawMiniMap(); }, 500); - }); - this.$bus.$on("view_data_change", () => { + }, + view_data_change() { if (!this.showMiniMap) { return; } @@ -71,9 +83,7 @@ export default { this.timer = setTimeout(() => { this.drawMiniMap(); }, 500); - }); - }, - methods: { + }, init() { let { width, height } = this.$refs.navigatorBox.getBoundingClientRect(); this.boxWidth = width;