-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
demo.vue
57 lines (53 loc) · 1.19 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
57
<script setup lang="ts">
import { computed } from '@vue/reactivity'
import { useWindowScroll } from '@vueuse/core'
import { ref } from 'vue'
const smooth = ref(false)
const behavior = computed(() => smooth.value ? 'smooth' : 'auto')
const { x, y } = useWindowScroll({ behavior })
</script>
<template>
<div>
<div>
See and control scroll values in the lower right corner of the screen.
</div>
<div class="scroller" />
<div class="float">
<note class="mb-2">
Scroll value
</note>
<label>
<input v-model="smooth" type="checkbox"> Smooth scroll
</label>
<p>x: {{ x }}</p>
<button class="extra-small" @click="x -= 200">
-200
</button>
<button class="extra-small" @click="x += 200">
+200
</button>
<hr>
<p>y: {{ y }}</p>
<button class="extra-small" @click="y -= 200">
-200
</button>
<button class="extra-small" @click="y += 200">
+200
</button>
</div>
</div>
</template>
<style scoped>
.scroller {
position: absolute;
top: 100%;
left: 100%;
width: 10000px;
height: 10000px;
}
label {
font-size: 0.8rem;
display: flex;
gap: 0.2rem;
}
</style>