Skip to content

Commit ddde22d

Browse files
committed
refactor(QVirtualScroll): rename QVirtualList to QVirtualScroll to reflect its new abilities (regarding type prop)
1 parent 6cd173c commit ddde22d

File tree

17 files changed

+148
-148
lines changed

17 files changed

+148
-148
lines changed

ui/dev/components/components/virtual-list-1.vue renamed to ui/dev/components/components/virtual-scroll-1.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Heavy test - Different components ({{ size.toLocaleString() }} items)
1919
</div>
2020
<q-list class="q-my-md bg-grey-10">
21-
<q-virtual-list
21+
<q-virtual-scroll
2222
style="max-height: 300px;"
2323
:items="heavyList"
2424
>
@@ -48,7 +48,7 @@
4848
{{ item.label }} #{{ index }}
4949
</div>
5050
</template>
51-
</q-virtual-list>
51+
</q-virtual-scroll>
5252
</q-list>
5353

5454
<div class="text-h6 q-mt-lg row items-center justify-between">
@@ -66,7 +66,7 @@
6666
@change="$refs.vList.scrollTo(scrollTo)"
6767
/>
6868
</div>
69-
<q-virtual-list component="q-list" ref="vList" :items="heavyList" separator class="q-my-md" style="max-height: 300px;">
69+
<q-virtual-scroll component="q-list" ref="vList" :items="heavyList" separator class="q-my-md" style="max-height: 300px;">
7070
<template v-slot="{ item, index }">
7171
<q-item :key="index">
7272
<q-item-section>
@@ -88,7 +88,7 @@
8888
</q-item-section>
8989
</q-item>
9090
</template>
91-
</q-virtual-list>
91+
</q-virtual-scroll>
9292

9393
<div class="text-h6 q-mt-lg row items-center justify-between">
9494
Horizontal - Variable size ({{ size.toLocaleString() }} items)
@@ -105,7 +105,7 @@
105105
@change="$refs.vListH.scrollTo(scrollToH)"
106106
/>
107107
</div>
108-
<q-virtual-list ref="vListH" virtual-list-horizontal :items="heavyList" class="q-my-md" style="max-width: 80vw; margin-bottom: 200vh;">
108+
<q-virtual-scroll ref="vListH" virtual-scroll-horizontal :items="heavyList" class="q-my-md" style="max-width: 80vw; margin-bottom: 200vh;">
109109
<template v-slot="{ item, index }">
110110
<div class="row no-wrap items-center" :key="index">
111111
<q-avatar square color="warning" text-color="negative">
@@ -120,7 +120,7 @@
120120
<q-separator v-if="index < heavyList.length - 1" vertical spaced />
121121
</div>
122122
</template>
123-
</q-virtual-list>
123+
</q-virtual-scroll>
124124
</q-page>
125125
</q-page-container>
126126
</q-layout>

ui/dev/components/components/virtual-list-2.vue renamed to ui/dev/components/components/virtual-scroll-2.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="text-h6 q-my-lg q-pa-lg bg-grey-10 text-white" style="height: 500px">
66
Before list
77
</div>
8-
<q-virtual-list component="q-list" :items="heavyList" separator scroll-target="body">
8+
<q-virtual-scroll component="q-list" :items="heavyList" separator scroll-target="body">
99
<template v-slot="{ item, index }">
1010
<q-item
1111
v-if="(index % 3) === 0"
@@ -30,7 +30,7 @@
3030
{{ item.label }} #{{ index }}
3131
</div>
3232
</template>
33-
</q-virtual-list>
33+
</q-virtual-scroll>
3434
<div class="text-h6 q-my-lg q-pa-lg bg-grey-10 text-white" style="height: 800px">
3535
After list
3636
</div>

ui/dev/components/components/virtual-list-3.vue renamed to ui/dev/components/components/virtual-scroll-3.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
Virtual list with dynamic generated items ({{ size.toLocaleString() }} items)
77
</div>
88

9-
<q-virtual-list
9+
<q-virtual-scroll
1010
class="bg-white col"
1111
component="q-list"
1212
:items-size="size"
1313
:items-fn="getItems"
14-
:virtual-list-item-size="5"
14+
:virtual-scroll-item-size="5"
1515
separator
1616
ref="list"
1717
>
@@ -36,7 +36,7 @@
3636
</q-item-section>
3737
</q-item>
3838
</template>
39-
</q-virtual-list>
39+
</q-virtual-scroll>
4040

4141
<div class="q-pa-md row justify-between">
4242
<q-btn label="+1e5" @click="() => { size += 1e5 }" />

ui/dev/components/components/virtual-list-4.vue renamed to ui/dev/components/components/virtual-scroll-4.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div class="text-h6 q-my-lg q-pa-lg bg-grey-10 text-white" style="height: 500px">
1212
Before list
1313
</div>
14-
<q-virtual-list component="q-list" :items="heavyList" separator :scroll-target="scrollTarget" @virtual-scroll="onVirtualScroll1">
14+
<q-virtual-scroll component="q-list" :items="heavyList" separator :scroll-target="scrollTarget" @virtual-scroll="onVirtualScroll1">
1515
<template v-slot="{ item, index }">
1616
<q-item
1717
v-if="(index % 3) === 0"
@@ -36,7 +36,7 @@
3636
{{ item.label }} #{{ index }}
3737
</div>
3838
</template>
39-
</q-virtual-list>
39+
</q-virtual-scroll>
4040
<div class="text-h6 q-my-lg q-pa-lg bg-grey-10 text-white" style="height: 800px">
4141
After list
4242
</div>
@@ -55,7 +55,7 @@
5555
/>
5656
</div>
5757

58-
<q-virtual-list
58+
<q-virtual-scroll
5959
ref="virtualListRef"
6060
class="q-my-md"
6161
style="max-height: 300px;"
@@ -81,7 +81,7 @@
8181
</q-item-section>
8282
</q-item>
8383
</template>
84-
</q-virtual-list>
84+
</q-virtual-scroll>
8585
</div>
8686
</q-page>
8787
</q-page-container>

ui/dev/components/components/virtual-list-5.vue renamed to ui/dev/components/components/virtual-scroll-5.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<q-layout view="lHh LpR fFf">
33
<q-page-container>
44
<q-page padding class="bg-white q-pr-xl">
5-
<q-virtual-list
5+
<q-virtual-scroll
66
type="table"
77
style="max-height: 70vh"
8-
:virtual-list-item-size="48"
8+
:virtual-scroll-item-size="48"
99
:items="heavyList"
1010
>
1111
<template v-slot:before>
@@ -51,7 +51,7 @@
5151
</td>
5252
</tr>
5353
</template>
54-
</q-virtual-list>
54+
</q-virtual-scroll>
5555
</q-page>
5656
</q-page-container>
5757
</q-layout>

ui/dev/components/form/select-part-3.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
style="width: 250px"
144144
clearable
145145
:behavior="behavior"
146-
virtual-list-horizontal
146+
virtual-scroll-horizontal
147147
>
148148
<template v-slot:no-option>
149149
<q-item>

ui/src/components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ export * from './components/tooltip/index.js'
5959
export * from './components/tree/index.js'
6060
export * from './components/uploader/index.js'
6161
export * from './components/video/index.js'
62-
export * from './components/virtual-list/index.js'
62+
export * from './components/virtual-scroll/index.js'

ui/src/components/list/list.styl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
border 1px solid $separator-color
8686
&--separator
8787
> .q-item-type + .q-item-type,
88-
> .q-virtual-list__content > .q-item-type + .q-item-type
88+
> .q-virtual-scroll__content > .q-item-type + .q-item-type
8989
border-top 1px solid $separator-color
9090
&--padding
9191
padding 8px 0
@@ -96,7 +96,7 @@
9696

9797
.q-list--dark.q-list--separator
9898
> .q-item-type + .q-item-type,
99-
> .q-virtual-list__content > .q-item-type + .q-item-type
99+
> .q-virtual-scroll__content > .q-item-type + .q-item-type
100100
border-top-color $separator-dark-color
101101

102102
.q-list--dark, .q-item--dark

ui/src/components/select/QSelect.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import { isDeepEqual } from '../../utils/is.js'
1515
import { stop, prevent, stopAndPrevent } from '../../utils/event.js'
1616
import { normalizeToInterval } from '../../utils/format.js'
1717

18-
import VirtualList from '../../mixins/virtual-list.js'
18+
import VirtualScroll from '../../mixins/virtual-scroll.js'
1919

2020
const validateNewValueMode = v => ['add', 'add-unique', 'toggle'].includes(v)
2121

2222
export default Vue.extend({
2323
name: 'QSelect',
2424

25-
mixins: [ QField, VirtualList ],
25+
mixins: [ QField, VirtualScroll ],
2626

2727
props: {
2828
value: {
@@ -122,7 +122,7 @@ export default Vue.extend({
122122
},
123123

124124
computed: {
125-
virtualListLength () {
125+
virtualScrollLength () {
126126
return Array.isArray(this.options)
127127
? this.options.length
128128
: 0
@@ -133,7 +133,7 @@ export default Vue.extend({
133133
},
134134

135135
menuContentClass () {
136-
return (this.virtualListHorizontal === true ? 'q-virtual-list--horizontal' : '') +
136+
return (this.virtualScrollHorizontal === true ? 'q-virtual-scroll--horizontal' : '') +
137137
(this.popupContentClass ? ' ' + this.popupContentClass : '')
138138
},
139139

@@ -158,7 +158,7 @@ export default Vue.extend({
158158
},
159159

160160
noOptions () {
161-
return this.virtualListLength.length === 0
161+
return this.virtualScrollLength.length === 0
162162
},
163163

164164
selectedString () {
@@ -191,11 +191,11 @@ export default Vue.extend({
191191
},
192192

193193
optionScope () {
194-
if (this.virtualListLength === 0) {
194+
if (this.virtualScrollLength === 0) {
195195
return []
196196
}
197197

198-
const { from, to } = this.virtualListSliceRange
198+
const { from, to } = this.virtualScrollSliceRange
199199

200200
return this.options.slice(from, to).map((opt, i) => {
201201
const disable = this.__isDisabled(opt)
@@ -359,7 +359,7 @@ export default Vue.extend({
359359
setOptionIndex (index) {
360360
if (this.$q.platform.is.desktop !== true) { return }
361361

362-
const val = index > -1 && index < this.virtualListLength
362+
const val = index > -1 && index < this.virtualScrollLength
363363
? index
364364
: -1
365365

@@ -446,7 +446,7 @@ export default Vue.extend({
446446
}
447447

448448
// up, down
449-
const optionsLength = this.virtualListLength
449+
const optionsLength = this.virtualScrollLength
450450

451451
if (e.keyCode === 38 || e.keyCode === 40) {
452452
stopAndPrevent(e)
@@ -531,7 +531,7 @@ export default Vue.extend({
531531
}
532532
},
533533

534-
__getVirtualListEl () {
534+
__getVirtualScrollEl () {
535535
return this.hasDialog === true
536536
? this.$refs.menuContent
537537
: (
@@ -541,8 +541,8 @@ export default Vue.extend({
541541
)
542542
},
543543

544-
__getVirtualListScrollTarget () {
545-
return this.__getVirtualListEl()
544+
__getVirtualScrollTarget () {
545+
return this.__getVirtualScrollEl()
546546
},
547547

548548
__getSelection (h, fromDialog) {
@@ -647,7 +647,7 @@ export default Vue.extend({
647647
])
648648
])
649649

650-
return this.__padVirtualList(h, 'div', this.optionScope.map(fn))
650+
return this.__padVirtualScroll(h, 'div', this.optionScope.map(fn))
651651
},
652652

653653
__getInnerAppend (h) {
@@ -875,7 +875,7 @@ export default Vue.extend({
875875
separateClosePopup: true
876876
},
877877
on: {
878-
'&scroll': this.__onVirtualListScroll,
878+
'&scroll': this.__onVirtualScrollEvt,
879879
'before-hide': this.__closeMenu
880880
}
881881
}, child)
@@ -931,7 +931,7 @@ export default Vue.extend({
931931
style: this.popupContentStyle,
932932
on: {
933933
click: prevent,
934-
'&scroll': this.__onVirtualListScroll
934+
'&scroll': this.__onVirtualScrollEvt
935935
}
936936
}, (
937937
this.noOptions === true
@@ -1033,7 +1033,7 @@ export default Vue.extend({
10331033
optionIndex = this.options.findIndex(v => isDeepEqual(this.__getOptionValue(v), val))
10341034
}
10351035

1036-
this.__resetVirtualList(optionIndex)
1036+
this.__resetVirtualScroll(optionIndex)
10371037
}
10381038

10391039
this.setOptionIndex(optionIndex)

ui/src/components/select/QSelect.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"mixins": [ "components/field/__QField", "mixins/virtual-list" ],
2+
"mixins": [ "components/field/__QField", "mixins/virtual-scroll" ],
33

44
"props": {
55
"value": {

0 commit comments

Comments
 (0)