From 04e3a787fcce5a5f3a3ab8cb561bc578e4d8f353 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 27 Oct 2023 17:13:01 +0900 Subject: [PATCH] fix: set `$clicks` to infinity on clicks disabled --- packages/client/internals/SlideWrapper.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/client/internals/SlideWrapper.ts b/packages/client/internals/SlideWrapper.ts index 9d1e4119a6..777e0c9b3a 100644 --- a/packages/client/internals/SlideWrapper.ts +++ b/packages/client/internals/SlideWrapper.ts @@ -1,6 +1,5 @@ import { useVModel } from '@vueuse/core' -import type { Ref } from 'vue' -import { defineComponent, h, provide, ref, toRef } from 'vue' +import { computed, defineComponent, h, provide, ref, toRef } from 'vue' import type { RenderContext } from '@slidev/types' import { injectionActive, injectionClicks, injectionClicksDisabled, injectionClicksElements, injectionCurrentPage, injectionOrderMap, injectionRenderContext, injectionRoute } from '../constants' @@ -48,11 +47,22 @@ export default defineComponent({ clicksElements.value.length = 0 + const clicksWithDisable = computed({ + get() { + if (clicksDisabled.value) + return 9999999 + return +clicks.value + }, + set(value) { + clicks.value = value + }, + }) + provide(injectionRoute, props.route as any) provide(injectionCurrentPage, ref(+props.route?.path)) provide(injectionRenderContext, ref(props.renderContext as RenderContext)) provide(injectionActive, toRef(props, 'active')) - provide(injectionClicks, clicks as Ref) + provide(injectionClicks, clicksWithDisable) provide(injectionClicksDisabled, clicksDisabled) provide(injectionClicksElements, clicksElements as any) provide(injectionOrderMap, clicksOrderMap as any)