|
4 | 4 | :code="code"
|
5 | 5 | :name="name"
|
6 | 6 | :options="options"
|
| 7 | + :script="script" |
7 | 8 | >
|
8 |
| - <v-responsive |
9 |
| - ref="responsive" |
10 |
| - class="overflow-y-auto" |
11 |
| - max-height="300" |
| 9 | + <v-sheet |
| 10 | + ref="sheetRef" |
| 11 | + :max-height="300" |
| 12 | + class="overflow-y-auto ma-4" |
| 13 | + elevation="5" |
12 | 14 | >
|
13 | 15 | <div class="pa-6 text-center position-sticky">
|
14 | 16 | Scroll down
|
|
22 | 24 |
|
23 | 25 | <v-lazy
|
24 | 26 | v-model="isActive"
|
25 |
| - :options="{ |
26 |
| - threshold: .5 |
27 |
| - }" |
| 27 | + :options="{ threshold: .5 }" |
28 | 28 | min-height="200"
|
29 | 29 | transition="fade-transition"
|
30 | 30 | >
|
31 | 31 | <v-card
|
32 | 32 | class="mx-auto"
|
| 33 | + color="primary" |
33 | 34 | max-width="336"
|
| 35 | + text="This card was rendered later" |
| 36 | + title="Lazy card" |
34 | 37 | >
|
35 |
| - <v-card-title>Card title</v-card-title> |
36 |
| - |
37 |
| - <v-card-text> |
38 |
| - Phasellus magna. Quisque rutrum. Nunc egestas, augue at pellentesque laoreet, felis eros vehicula leo, at malesuada velit leo quis pede. Aliquam lobortis. Quisque libero metus, condimentum nec, tempor a, commodo mollis, magna. |
39 |
| - |
40 |
| - In turpis. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. In turpis. Pellentesque dapibus hendrerit tortor. Ut varius tincidunt libero. |
41 |
| - </v-card-text> |
42 |
| - |
43 | 38 | <v-card-actions class="justify-center">
|
44 | 39 | <v-btn @click="reset">Reset Demo</v-btn>
|
45 | 40 | </v-card-actions>
|
46 | 41 | </v-card>
|
47 | 42 | </v-lazy>
|
48 |
| - <br> |
49 |
| - </v-responsive> |
| 43 | + </v-sheet> |
50 | 44 | </ExamplesUsageExample>
|
51 | 45 | </template>
|
52 | 46 |
|
|
56 | 50 | const name = 'v-lazy'
|
57 | 51 | const model = shallowRef('default')
|
58 | 52 | const isActive = shallowRef(false)
|
59 |
| - const responsive = ref() |
| 53 | + const sheetRef = ref() |
60 | 54 | const options = []
|
61 | 55 |
|
62 | 56 | async function reset () {
|
63 |
| - await goTo(0, { container: responsive.value.$el }) |
| 57 | + await goTo(0, { container: sheetRef.value.$el }) |
64 | 58 |
|
65 | 59 | isActive.value = false
|
66 | 60 | }
|
67 | 61 |
|
68 | 62 | const props = computed(() => {
|
69 | 63 | return {
|
| 64 | + 'v-model': 'isActive', |
70 | 65 | 'min-height': 200,
|
71 | 66 | options: { threshold: 0.5 },
|
72 | 67 | transition: 'fade-transition',
|
|
75 | 70 |
|
76 | 71 | const slots = computed(() => {
|
77 | 72 | return `
|
78 |
| - <div class="text-center text-body-2 mb-12"> |
79 |
| - The card will appear below: |
80 |
| - </div> |
81 |
| -
|
82 | 73 | <v-card
|
83 | 74 | class="mx-auto"
|
| 75 | + color="primary" |
84 | 76 | max-width="336"
|
85 |
| - text="Phasellus magna. Quisque rutrum. Nunc egestas, augue at pellentesque laoreet." |
86 |
| - title="Card title" |
| 77 | + text="This card was rendered later" |
| 78 | + title="Lazy card" |
87 | 79 | >
|
88 | 80 | <v-card-actions class="justify-center">
|
89 | 81 | <v-btn @click="reset">Reset Demo</v-btn>
|
|
92 | 84 | `
|
93 | 85 | })
|
94 | 86 |
|
| 87 | + const script = computed(() => { |
| 88 | + return `<script setup> |
| 89 | + import { ref, shallowRef } from 'vue' |
| 90 | + import { useGoTo } from 'vuetify' |
| 91 | +
|
| 92 | + const goTo = useGoTo() |
| 93 | +
|
| 94 | + const isActive = shallowRef(false) |
| 95 | + const sheetRef = ref() |
| 96 | +
|
| 97 | + async function reset () { |
| 98 | + await goTo(0, { container: sheetRef.value.$el }) |
| 99 | +
|
| 100 | + isActive.value = false |
| 101 | + } |
| 102 | +<` + '/script>' |
| 103 | + }) |
| 104 | +
|
95 | 105 | const code = computed(() => {
|
96 |
| - return `<v-lazy${propsToString(props.value)}>${slots.value}</v-lazy>` |
| 106 | + return `<v-sheet |
| 107 | + ref="sheetRef" |
| 108 | + class="overflow-y-auto ma-4" |
| 109 | + :max-height="300" |
| 110 | + elevation="5" |
| 111 | +> |
| 112 | + <div class="pa-6 text-center position-sticky">Scroll down</div> |
| 113 | + <v-responsive min-height="100vh"></v-responsive> |
| 114 | +
|
| 115 | + <div class="text-center text-body-2 mb-12"> |
| 116 | + The card will appear below: |
| 117 | + </div> |
| 118 | +
|
| 119 | + <${name}${propsToString(props.value)}>${slots.value}</${name}> |
| 120 | +</v-sheet>` |
97 | 121 | })
|
98 | 122 | </script>
|
0 commit comments