forked from vitest-dev/vitest
/
demo.vue
33 lines (27 loc) · 792 Bytes
/
demo.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<script setup lang="ts">
import { ref } from 'vue-demi'
import { onLongPress } from '.'
const htmlRef = ref<HTMLElement | null>(null)
const htmlRefOptions = ref<HTMLElement | null>(null)
const longPressed = ref(false)
const onLongPressCallback = (e: PointerEvent) => {
longPressed.value = true
}
const reset = () => {
longPressed.value = false
}
onLongPress(htmlRef, onLongPressCallback)
onLongPress(htmlRefOptions, onLongPressCallback, { delay: 1000 })
</script>
<template>
<p>Long Pressed: {{ longPressed }}</p>
<button ref="htmlRef" class="ml-2 button small">
Press long (500ms)
</button>
<button ref="htmlRefOptions" class="ml-2 button small">
Press long (1000ms)
</button>
<button class="ml-2 button small" @click="reset">
Reset
</button>
</template>