forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollPosition.vue
More file actions
42 lines (36 loc) · 1.05 KB
/
ScrollPosition.vue
File metadata and controls
42 lines (36 loc) · 1.05 KB
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
<template>
<div class="q-pa-md">
<div class="row q-gutter-md q-mb-md">
<q-btn :label="`Scroll to ${position}px`" color="primary" @click="scroll" />
<q-btn :label="`Animate to ${position}px`" color="primary" @click="animateScroll" />
</div>
<q-scroll-area ref="scrollAreaRef" style="height: 150px; max-width: 300px;">
<ol>
<li v-for="n in 1000" :key="n">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</li>
</ol>
</q-scroll-area>
</div>
</template>
<script>
import { ref } from 'vue'
export default {
setup () {
const position = ref(300)
const scrollAreaRef = ref(null)
return {
position,
scrollAreaRef,
scroll () {
scrollAreaRef.value.setScrollPosition('vertical', position.value)
position.value = Math.floor(Math.random() * 1001) * 20
},
animateScroll () {
scrollAreaRef.value.setScrollPosition('vertical', position.value, 300)
position.value = Math.floor(Math.random() * 1001) * 20
}
}
}
}
</script>