From f09faa3944997876f41ad2f2fb0ac48ab72e24ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 17 Jan 2021 18:04:00 +0100 Subject: [PATCH] fix space -> home not working if location in hash --- app/src/components/SVGContent.vue | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/components/SVGContent.vue b/app/src/components/SVGContent.vue index bcf61d9..1e4e4ef 100644 --- a/app/src/components/SVGContent.vue +++ b/app/src/components/SVGContent.vue @@ -201,6 +201,14 @@ export default defineComponent({ // Process start element const start = processStart(svg); + if (start) { + console.info("[SVG] Found start element."); + window.addEventListener("keydown", (ev) => { + if (ev.key === " ") { + panToElement(start, true); + } + }); + } // Pan to start element or location in hash const locationMatch = window.location.href.match(/#([\-0-9.]+),([\-0-9.]+),([0-9.]+)z/); @@ -216,14 +224,8 @@ export default defineComponent({ ); pz.zoomAbs(window.innerWidth / 2, window.innerHeight / 2, parseFloat(z)); } else if (start) { - console.info("[SVG] Found start element."); + console.debug(`[SVGCONTENT] Panning to start anchor.`); panToElement(start, false); - - window.addEventListener("keydown", (ev) => { - if (ev.key === " ") { - panToElement(start, true); - } - }); } // Anchors