forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollingCards.vue
More file actions
50 lines (45 loc) · 1.17 KB
/
ScrollingCards.vue
File metadata and controls
50 lines (45 loc) · 1.17 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
<template>
<div class="q-pa-md">
<div class="row justify-center q-gutter-sm">
<div
v-for="index in inView.length"
:key="index"
:data-id="index - 1"
class="example-item q-pa-sm flex flex-center relative-position"
v-intersection="onIntersection"
>
<transition name="q-transition--scale">
<q-card v-if="inView[index - 1]">
<img src="https://cdn.quasar.dev/img/mountains.jpg">
<q-card-section>
<div class="text-h6">Card #{{ index }}</div>
<div class="text-subtitle2">by John Doe</div>
</q-card-section>
</q-card>
</transition>
</div>
</div>
</div>
</template>
<script>
import { ref } from 'vue'
export default {
setup () {
const inView = ref(Array.apply(null, Array(50)).map(_ => false))
return {
inView,
onIntersection (entry) {
const index = parseInt(entry.target.dataset.id, 10)
setTimeout(() => {
inView.value.splice(index, 1, entry.isIntersecting)
}, 50)
}
}
}
}
</script>
<style lang="sass" scoped>
.example-item
height: 290px
width: 290px
</style>