From 2759cb07fed57a73845efbf23df93aa360bee373 Mon Sep 17 00:00:00 2001 From: "Ng Wing Tat, David" Date: Sun, 18 Aug 2024 02:08:56 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Improve=20mobile=20navigation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #4 --- pages/index.vue | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pages/index.vue b/pages/index.vue index cd4b169..98914c2 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -227,4 +227,19 @@ useEventListener("keydown", (event) => { break; } }); + +useEventListener(renditionEl.value, "click", (event) => { + if ('ontouchstart' in window && renditionEl.value) { + const width = renditionEl.value.clientWidth; + const x = event.clientX % width; + const threshold = 0.3; + const side = width * threshold; + + if (x < side) { + prevPage(); + } else if (width - x < side) { + nextPage(); + } + } +});