From 9e9f0e3d4dcc61d7887f48f1f3099a4b6d029124 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 6 Oct 2020 16:41:02 +0800 Subject: [PATCH] types: improve useTouch typing --- src/composition/use-touch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/composition/use-touch.ts b/src/composition/use-touch.ts index a4a65a2df..7becdd053 100644 --- a/src/composition/use-touch.ts +++ b/src/composition/use-touch.ts @@ -2,15 +2,15 @@ import { ref } from 'vue'; const MIN_DISTANCE = 10; +type Direction = '' | 'vertical' | 'horizontal'; + function getDirection(x: number, y: number) { if (x > y && x > MIN_DISTANCE) { return 'horizontal'; } - if (y > x && y > MIN_DISTANCE) { return 'vertical'; } - return ''; } @@ -21,7 +21,7 @@ export function useTouch() { const deltaY = ref(0); const offsetX = ref(0); const offsetY = ref(0); - const direction = ref(''); + const direction = ref(''); const isVertical = () => direction.value === 'vertical'; const isHorizontal = () => direction.value === 'horizontal';