forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectForm.vue
More file actions
79 lines (67 loc) · 1.4 KB
/
ObjectForm.vue
File metadata and controls
79 lines (67 loc) · 1.4 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<template>
<div class="relative-position">
<div
class="example-state rounded-borders text-center absolute-top q-mt-md q-ml-md q-mr-lg text-white"
:class="visibleClass"
>
Percent: {{ percent }}%
</div>
<div class="example-area q-pa-lg scroll">
<div class="example-filler" />
<div v-intersection="options" class="example-observed flex flex-center rounded-borders">
Observed Element
</div>
<div class="example-filler" />
</div>
</div>
</template>
<script>
const thresholds = []
for (let i = 0; i <= 1.0; i += 0.01) {
thresholds.push(i)
}
export default {
data () {
return {
percent: 0,
options: {
handler: this.onIntersection,
cfg: {
threshold: thresholds
}
}
}
},
computed: {
visibleClass () {
return `bg-${this.percent > 0 ? 'positive' : 'negative'}`
}
},
methods: {
onIntersection (entry) {
const percent = (entry.intersectionRatio * 100).toFixed(0)
if (this.percent !== percent) {
this.percent = percent
}
}
}
}
</script>
<style lang="sass" scoped>
.example-state
background: #ccc
font-size: 20px
color: #282a37
padding: 10px
opacity: 0.8
.example-observed
height: 150px
font-size: 20px
color: #ccc
background: #282a37
padding: 10px
.example-area
height: 300px
.example-filler
height: 500px
</style>