forked from vitest-dev/vitest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.vue
56 lines (54 loc) · 1.78 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<script setup lang="ts">
import { ref, toRefs } from 'vue-demi'
import { useScroll } from '.'
const el = ref<HTMLElement | null>(null)
const { x, y, isScrolling, arrivedState } = useScroll(el)
const { left, right, top, bottom } = toRefs(arrivedState)
</script>
<template>
<div class="flex">
<div ref="el" class="w-300px h-300px m-auto overflow-scroll bg-gray-500/5 rounded">
<div class="w-500px h-400px relative">
<div position="absolute left-0 top-0" bg="gray-500/5" p="x-2 y-1">
TopLeft
</div>
<div position="absolute left-0 bottom-0" bg="gray-500/5" p="x-2 y-1">
BottomLeft
</div>
<div position="absolute right-0 top-0" bg="gray-500/5" p="x-2 y-1">
TopRight
</div>
<div position="absolute right-0 bottom-0" bg="gray-500/5" p="x-2 y-1">
BottomRight
</div>
<div position="absolute left-1/3 top-1/3" bg="gray-500/5" p="x-2 y-1">
Scroll Me
</div>
</div>
</div>
<div class="m-auto w-280px px-6 py-4 mb-20 rounded grid grid-cols-[120px,auto] gap-2 bg-gray-500/5">
<span text="right" opacity="75">Position</span>
<div class="text-primary">
{{ x }}, {{ y }}
</div>
<span text="right" opacity="75">isScrolling</span>
<BooleanDisplay :value="isScrolling" />
<div text="right" opacity="75">
Top Arrived
</div>
<BooleanDisplay :value="top" />
<div text="right" opacity="75">
Right Arrived
</div>
<BooleanDisplay :value="right" />
<div text="right" opacity="75">
Bottom Arrived
</div>
<BooleanDisplay :value="bottom" />
<div text="right" opacity="75">
Left Arrived
</div>
<BooleanDisplay :value="left" />
</div>
</div>
</template>