From 3a4a5dc6f00bcddb16a40853fa6d618471678832 Mon Sep 17 00:00:00 2001 From: samunohito <46447427+samunohito@users.noreply.github.com> Date: Tue, 6 Feb 2024 20:42:43 +0900 Subject: [PATCH] fix paging --- packages/frontend/src/components/MkPagingButtons.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/components/MkPagingButtons.vue b/packages/frontend/src/components/MkPagingButtons.vue index 664fcf6ab2..80fabacb19 100644 --- a/packages/frontend/src/components/MkPagingButtons.vue +++ b/packages/frontend/src/components/MkPagingButtons.vue @@ -43,14 +43,19 @@ const props = defineProps<{ buttonCount: number; }>(); -const { current, max, buttonCount } = toRefs(props); +const { current, max } = toRefs(props); +const buttonCount = computed(() => Math.min(max.value, props.buttonCount)); const buttonCountHalf = computed(() => Math.floor(buttonCount.value / 2)); const buttonCountStart = computed(() => Math.min(Math.max(min, current.value - buttonCountHalf.value), max.value - buttonCount.value + 1)); const buttonRanges = computed(() => Array.from({ length: buttonCount.value }, (_, i) => buttonCountStart.value + i)); -const prevDotVisible = computed(() => (current.value - 1 > buttonCountHalf.value) || (max.value < buttonCount.value)); -const nextDotVisible = computed(() => (current.value < max.value - buttonCountHalf.value) || (max.value < buttonCount.value)); +const prevDotVisible = computed(() => (current.value - 1 > buttonCountHalf.value) && (max.value > buttonCount.value)); +const nextDotVisible = computed(() => (current.value < max.value - buttonCountHalf.value) && (max.value > buttonCount.value)); + +console.log(current.value, max.value, buttonCount.value, buttonCountHalf.value); +console.log(current.value < max.value - buttonCountHalf.value); +console.log(max.value > buttonCount.value); function onNumberButtonClicked(pageNumber: number) { emit('pageChanged', pageNumber);