From 8d5739d4d06a1c8c20e94d338500a55e21d06097 Mon Sep 17 00:00:00 2001 From: Reilly Krause <89659007+Mast3Rei@users.noreply.github.com> Date: Wed, 7 Aug 2024 12:07:52 -0700 Subject: [PATCH] Complete arrow and swipe between books control (#656) Arrows disappear and swipe blocked at the correct locations when 'book-swipe-between-books' is disabled --- src/routes/text/+page.svelte | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/routes/text/+page.svelte b/src/routes/text/+page.svelte index d22c975d..5f6fefa1 100644 --- a/src/routes/text/+page.svelte +++ b/src/routes/text/+page.svelte @@ -71,9 +71,16 @@ refs.subscribe((value) => { savedScrollPosition = 0; }); + + const swipeBetweenBooks = config.mainFeatures['book-swipe-between-books']; async function doSwipe(event) { - console.log('SWIPE', event.detail.direction); - await navigateToTextChapterInDirection(event.detail.direction === 'right' ? -1 : 1); + const swipeDirection = event.detail.direction; + console.log('SWIPE', swipeDirection); + if (swipeBetweenBooks || + ($refs.prev.book === $refs.book && swipeDirection === 'right') || + ($refs.next.book === $refs.book && swipeDirection === 'left')) { + await navigateToTextChapterInDirection(swipeDirection === 'right' ? -1 : 1); + } } async function prevChapter() { @@ -83,6 +90,8 @@ await navigateToTextChapterInDirection(1); } + $: navigateBetweenBooksPrev = swipeBetweenBooks || $refs.prev.book === $refs.book; + $: navigateBetweenBooksNext = swipeBetweenBooks || $refs.next.book === $refs.book; $: hasPrev = $refs.prev.chapter !== null; $: hasNext = $refs.next.chapter !== null; $: viewShowVerses = @@ -406,7 +415,7 @@