Skip to content

Commit

Permalink
fix: complete state for hasNext and hasPrev (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
dizys committed May 26, 2021
1 parent 981f007 commit fdd88ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/client/logic/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export const currentPath = computed(() => getPath(currentPage.value))
export const currentRoute = computed(() => rawRoutes.find(i => i.path === `${currentPage.value}`))
export const currentSlideId = computed(() => currentRoute.value?.meta?.slide?.id)

export const hasNext = computed(() => currentPage.value < rawRoutes.length - 1)
export const hasPrev = computed(() => currentPage.value > 1)
export const nextRoute = computed(() => rawRoutes.find(i => i.path === `${Math.min(rawRoutes.length, currentPage.value + 1)}`))

export const clicksElements = computed<HTMLElement[]>(() => currentRoute.value?.meta?.__clicksElements || [])
Expand All @@ -40,6 +38,9 @@ export const clicks = computed<number>({

export const clicksTotal = computed(() => +(currentRoute.value?.meta?.clicks ?? clicksElements.value.length))

export const hasNext = computed(() => currentPage.value < rawRoutes.length - 1 || clicks.value < clicksTotal.value)
export const hasPrev = computed(() => currentPage.value > 1 || clicks.value > 0)

export function next() {
if (clicksTotal.value <= clicks.value)
nextSlide()
Expand Down

0 comments on commit fdd88ca

Please sign in to comment.