primevue 3.9.1 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/Accordion.d.ts +74 -11
- package/accordiontab/AccordionTab.d.ts +37 -8
- package/api/Api.d.ts +292 -285
- package/autocomplete/AutoComplete.d.ts +279 -62
- package/avatar/Avatar.d.ts +57 -8
- package/avatargroup/AvatarGroup.d.ts +29 -3
- package/badge/Badge.d.ts +46 -5
- package/blockui/BlockUI.d.ts +52 -11
- package/breadcrumb/Breadcrumb.d.ts +49 -9
- package/button/Button.d.ts +68 -11
- package/calendar/Calendar.d.ts +322 -62
- package/calendar/Calendar.vue +48 -20
- package/calendar/calendar.cjs.js +120 -93
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +120 -92
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +122 -94
- package/calendar/calendar.min.js +1 -1
- package/card/Card.d.ts +43 -9
- package/carousel/Carousel.d.ts +121 -24
- package/cascadeselect/CascadeSelect.d.ts +164 -31
- package/chart/Chart.d.ts +104 -12
- package/chart/Chart.vue +9 -2
- package/chart/chart.cjs.js +9 -2
- package/chart/chart.cjs.min.js +1 -1
- package/chart/chart.esm.js +9 -2
- package/chart/chart.esm.min.js +1 -1
- package/chart/chart.js +9 -2
- package/chart/chart.min.js +1 -1
- package/checkbox/Checkbox.d.ts +65 -7
- package/chip/Chip.d.ts +50 -4
- package/chips/Chips.d.ts +88 -15
- package/colorpicker/ColorPicker.d.ts +105 -16
- package/column/Column.d.ts +448 -78
- package/columngroup/ColumnGroup.d.ts +30 -4
- package/confirmationoptions/ConfirmationOptions.d.ts +50 -0
- package/confirmationoptions/package.json +3 -0
- package/confirmationservice/ConfirmationService.d.ts +2 -1
- package/confirmdialog/ConfirmDialog.d.ts +57 -5
- package/confirmpopup/ConfirmPopup.d.ts +38 -7
- package/contextmenu/ContextMenu.d.ts +88 -16
- package/core/core.js +364 -268
- package/core/core.min.js +2 -2
- package/datatable/BodyCell.vue +26 -1
- package/datatable/DataTable.d.ts +1056 -131
- package/datatable/DataTable.vue +102 -81
- package/datatable/HeaderCheckbox.vue +4 -1
- package/datatable/TableBody.vue +53 -14
- package/datatable/datatable.cjs.js +414 -307
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +414 -308
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +415 -309
- package/datatable/datatable.min.js +1 -1
- package/dataview/DataView.d.ts +198 -32
- package/dataviewlayoutoptions/DataViewLayoutOptions.d.ts +34 -5
- package/deferredcontent/DeferredContent.d.ts +31 -6
- package/dialog/Dialog.d.ts +188 -35
- package/divider/Divider.d.ts +53 -8
- package/dock/Dock.d.ts +92 -15
- package/dropdown/Dropdown.d.ts +335 -76
- package/editor/Editor.d.ts +78 -11
- package/fieldset/Fieldset.d.ts +63 -11
- package/fileupload/FileUpload.d.ts +255 -37
- package/fullcalendar/FullCalendar.d.ts +29 -3
- package/galleria/Galleria.d.ts +196 -46
- package/image/Image.d.ts +51 -6
- package/inlinemessage/InlineMessage.d.ts +34 -6
- package/inplace/Inplace.d.ts +57 -12
- package/inputmask/InputMask.d.ts +75 -15
- package/inputnumber/InputNumber.d.ts +180 -30
- package/inputswitch/InputSwitch.d.ts +61 -9
- package/inputtext/InputText.d.ts +34 -5
- package/knob/Knob.d.ts +92 -18
- package/listbox/Listbox.d.ts +240 -55
- package/megamenu/MegaMenu.d.ts +60 -12
- package/menu/Menu.d.ts +84 -15
- package/menubar/Menubar.d.ts +52 -11
- package/menuitem/MenuItem.d.ts +80 -0
- package/menuitem/package.json +3 -0
- package/message/Message.d.ts +57 -11
- package/multiselect/MultiSelect.d.ts +363 -83
- package/orderlist/OrderList.d.ts +122 -19
- package/organizationchart/OrganizationChart.d.ts +137 -15
- package/overlaypanel/OverlayPanel.d.ts +107 -12
- package/package.json +1 -1
- package/paginator/Paginator.d.ts +129 -27
- package/panel/Panel.d.ts +64 -9
- package/panelmenu/PanelMenu.d.ts +59 -11
- package/panelmenu/PanelMenu.vue +2 -2
- package/panelmenu/panelmenu.cjs.js +4 -4
- package/panelmenu/panelmenu.cjs.min.js +1 -1
- package/panelmenu/panelmenu.esm.js +4 -4
- package/panelmenu/panelmenu.esm.min.js +1 -1
- package/panelmenu/panelmenu.js +4 -4
- package/panelmenu/panelmenu.min.js +1 -1
- package/password/Password.d.ts +115 -24
- package/picklist/PickList.d.ts +199 -32
- package/progressbar/ProgressBar.d.ts +43 -8
- package/progressspinner/ProgressSpinner.d.ts +39 -6
- package/radiobutton/RadioButton.d.ts +51 -6
- package/rating/Rating.d.ts +67 -10
- package/resources/themes/arya-blue/theme.css +5 -1
- package/resources/themes/arya-green/theme.css +5 -1
- package/resources/themes/arya-orange/theme.css +5 -1
- package/resources/themes/arya-purple/theme.css +5 -1
- package/resources/themes/bootstrap4-dark-blue/theme.css +5 -1
- package/resources/themes/bootstrap4-dark-purple/theme.css +5 -1
- package/resources/themes/bootstrap4-light-blue/theme.css +5 -1
- package/resources/themes/bootstrap4-light-purple/theme.css +5 -1
- package/resources/themes/fluent-light/theme.css +5 -1
- package/resources/themes/lara-dark-blue/theme.css +43 -39
- package/resources/themes/lara-dark-indigo/theme.css +43 -39
- package/resources/themes/lara-dark-purple/theme.css +43 -39
- package/resources/themes/lara-dark-teal/theme.css +43 -39
- package/resources/themes/lara-light-blue/theme.css +5 -1
- package/resources/themes/lara-light-indigo/theme.css +5 -1
- package/resources/themes/lara-light-purple/theme.css +5 -1
- package/resources/themes/lara-light-teal/theme.css +5 -1
- package/resources/themes/luna-amber/theme.css +5 -1
- package/resources/themes/luna-blue/theme.css +5 -1
- package/resources/themes/luna-green/theme.css +5 -1
- package/resources/themes/luna-pink/theme.css +5 -1
- package/resources/themes/md-dark-deeppurple/theme.css +5 -1
- package/resources/themes/md-dark-indigo/theme.css +5 -1
- package/resources/themes/md-light-deeppurple/theme.css +5 -1
- package/resources/themes/md-light-indigo/theme.css +5 -1
- package/resources/themes/mdc-dark-deeppurple/theme.css +5 -1
- package/resources/themes/mdc-dark-indigo/theme.css +5 -1
- package/resources/themes/mdc-light-deeppurple/theme.css +5 -1
- package/resources/themes/mdc-light-indigo/theme.css +5 -1
- package/resources/themes/nova/theme.css +5 -1
- package/resources/themes/nova-accent/theme.css +5 -1
- package/resources/themes/nova-alt/theme.css +5 -1
- package/resources/themes/nova-vue/theme.css +5 -1
- package/resources/themes/rhea/theme.css +5 -1
- package/resources/themes/saga-blue/theme.css +5 -1
- package/resources/themes/saga-green/theme.css +5 -1
- package/resources/themes/saga-orange/theme.css +5 -1
- package/resources/themes/saga-purple/theme.css +5 -1
- package/resources/themes/tailwind-light/theme.css +5 -1
- package/resources/themes/vela-blue/theme.css +5 -1
- package/resources/themes/vela-green/theme.css +5 -1
- package/resources/themes/vela-orange/theme.css +5 -1
- package/resources/themes/vela-purple/theme.css +5 -1
- package/row/Row.d.ts +25 -3
- package/scrollpanel/ScrollPanel.d.ts +27 -5
- package/scrolltop/ScrollTop.d.ts +47 -7
- package/selectbutton/SelectButton.d.ts +101 -17
- package/sidebar/Sidebar.d.ts +81 -16
- package/skeleton/Skeleton.d.ts +58 -9
- package/slider/Slider.d.ts +90 -14
- package/speeddial/SpeedDial.d.ts +166 -29
- package/splitbutton/SplitButton.d.ts +71 -11
- package/splitter/Splitter.d.ts +74 -7
- package/splitterpanel/SplitterPanel.d.ts +34 -7
- package/steps/Steps.d.ts +51 -11
- package/tabmenu/TabMenu.d.ts +63 -10
- package/tabpanel/TabPanel.d.ts +34 -7
- package/tabview/TabView.d.ts +73 -11
- package/tag/Tag.d.ts +44 -8
- package/terminal/Terminal.d.ts +36 -5
- package/terminalservice/TerminalService.d.ts +1 -1
- package/textarea/Textarea.d.ts +38 -6
- package/tieredmenu/TieredMenu.d.ts +89 -15
- package/timeline/Timeline.d.ts +94 -15
- package/toast/Toast.d.ts +110 -12
- package/toastservice/ToastService.d.ts +17 -5
- package/togglebutton/ToggleButton.d.ts +64 -11
- package/toolbar/Toolbar.d.ts +31 -6
- package/tree/Tree.d.ts +189 -26
- package/treeselect/TreeSelect.d.ts +201 -44
- package/treetable/TreeTable.d.ts +459 -63
- package/tristatecheckbox/TriStateCheckbox.d.ts +39 -5
- package/ts-helpers.d.ts +28 -0
- package/useconfirm/UseConfirm.d.ts +5 -19
- package/usetoast/UseToast.d.ts +3 -5
- package/utils/Utils.d.ts +3 -0
- package/utils/utils.cjs.js +39 -2
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +39 -2
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +39 -2
- package/utils/utils.min.js +1 -1
- package/vetur-attributes.json +57 -25
- package/vetur-tags.json +11 -3
- package/virtualscroller/VirtualScroller.d.ts +294 -53
- package/virtualscroller/VirtualScroller.vue +296 -255
- package/virtualscroller/virtualscroller.cjs.js +325 -266
- package/virtualscroller/virtualscroller.cjs.min.js +1 -1
- package/virtualscroller/virtualscroller.esm.js +325 -266
- package/virtualscroller/virtualscroller.esm.min.js +1 -1
- package/virtualscroller/virtualscroller.js +325 -266
- package/virtualscroller/virtualscroller.min.js +1 -1
- package/web-types.json +153 -28
|
@@ -1,41 +1,50 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<template v-if="!disabled">
|
|
3
|
-
<div :ref="elementRef" :class="containerClass" :style="style" @scroll="onScroll">
|
|
4
|
-
<slot name="content" styleClass="
|
|
5
|
-
|
|
3
|
+
<div :ref="elementRef" :class="containerClass" :tabindex="0" :style="style" @scroll="onScroll">
|
|
4
|
+
<slot name="content" :styleClass="contentClass" :items="loadedItems" :getItemOptions="getOptions" :loading="d_loading" :getLoaderOptions="getLoaderOptions" :itemSize="itemSize"
|
|
5
|
+
:rows="loadedRows" :columns="loadedColumns" :contentRef="contentRef" :spacerStyle="spacerStyle" :contentStyle="contentStyle"
|
|
6
|
+
:vertical="isVertical()" :horizontal="isHorizontal()" :both="isBoth()">
|
|
7
|
+
<div :ref="contentRef" :class="contentClass" :style="contentStyle">
|
|
6
8
|
<template v-for="(item, index) of loadedItems" :key="index">
|
|
7
9
|
<slot name="item" :item="item" :options="getOptions(index)"></slot>
|
|
8
10
|
</template>
|
|
9
11
|
</div>
|
|
10
12
|
</slot>
|
|
11
|
-
<div
|
|
12
|
-
<div :class="loaderClass" v-if="d_loading">
|
|
13
|
-
<template v-
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
</
|
|
13
|
+
<div class="p-virtualscroller-spacer" :style="spacerStyle" v-if="showSpacer"></div>
|
|
14
|
+
<div :class="loaderClass" v-if="!loaderDisabled && showLoader && d_loading">
|
|
15
|
+
<template v-if="$slots && $slots.loader">
|
|
16
|
+
<template v-for="(_, index) of loaderArr" :key="index">
|
|
17
|
+
<slot name="loader" :options="getLoaderOptions(index, isBoth() && { numCols: d_numItemsInViewport.cols })"></slot>
|
|
18
|
+
</template>
|
|
17
19
|
</template>
|
|
20
|
+
<i v-else class="p-virtualscroller-loading-icon pi pi-spinner pi-spin"></i>
|
|
18
21
|
</div>
|
|
19
22
|
</div>
|
|
20
23
|
</template>
|
|
21
24
|
<template v-else>
|
|
22
25
|
<slot></slot>
|
|
23
|
-
<slot name="content" :items="items"></slot>
|
|
26
|
+
<slot name="content" :items="items" :rows="items" :columns="loadedColumns"></slot>
|
|
24
27
|
</template>
|
|
25
28
|
</template>
|
|
26
29
|
|
|
27
30
|
<script>
|
|
28
31
|
export default {
|
|
29
32
|
name: 'VirtualScroller',
|
|
30
|
-
emits: ['update:numToleratedItems', 'scroll-index-change', 'lazy-load'],
|
|
33
|
+
emits: ['update:numToleratedItems', 'scroll', 'scroll-index-change', 'lazy-load'],
|
|
31
34
|
props: {
|
|
35
|
+
id: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: null
|
|
38
|
+
},
|
|
39
|
+
style: null,
|
|
40
|
+
class: null,
|
|
32
41
|
items: {
|
|
33
42
|
type: Array,
|
|
34
43
|
default: null
|
|
35
44
|
},
|
|
36
45
|
itemSize: {
|
|
37
46
|
type: [Number,Array],
|
|
38
|
-
default:
|
|
47
|
+
default: 0
|
|
39
48
|
},
|
|
40
49
|
scrollHeight: null,
|
|
41
50
|
scrollWidth: null,
|
|
@@ -55,17 +64,27 @@ export default {
|
|
|
55
64
|
type: Boolean,
|
|
56
65
|
default: false
|
|
57
66
|
},
|
|
58
|
-
|
|
67
|
+
disabled: {
|
|
59
68
|
type: Boolean,
|
|
60
69
|
default: false
|
|
61
70
|
},
|
|
71
|
+
loaderDisabled: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
columns: {
|
|
76
|
+
type: Array,
|
|
77
|
+
default: null
|
|
78
|
+
},
|
|
62
79
|
loading: {
|
|
63
80
|
type: Boolean,
|
|
64
81
|
default: false
|
|
65
82
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
showSpacer: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: true
|
|
86
|
+
},
|
|
87
|
+
showLoader: {
|
|
69
88
|
type: Boolean,
|
|
70
89
|
default: false
|
|
71
90
|
}
|
|
@@ -78,15 +97,19 @@ export default {
|
|
|
78
97
|
lastScrollPos: this.isBoth() ? { top: 0, left: 0 } : 0,
|
|
79
98
|
d_numToleratedItems: this.numToleratedItems,
|
|
80
99
|
d_loading: this.loading,
|
|
81
|
-
loaderArr:
|
|
100
|
+
loaderArr: [],
|
|
101
|
+
spacerStyle: {},
|
|
102
|
+
contentStyle: {}
|
|
82
103
|
}
|
|
83
104
|
},
|
|
84
105
|
element: null,
|
|
85
106
|
content: null,
|
|
86
|
-
|
|
107
|
+
lastScrollPos: null,
|
|
87
108
|
scrollTimeout: null,
|
|
88
109
|
mounted() {
|
|
89
110
|
this.init();
|
|
111
|
+
|
|
112
|
+
this.lastScrollPos = this.isBoth() ? { top: 0, left: 0 } : 0;
|
|
90
113
|
},
|
|
91
114
|
watch: {
|
|
92
115
|
numToleratedItems(newValue) {
|
|
@@ -95,67 +118,185 @@ export default {
|
|
|
95
118
|
loading(newValue) {
|
|
96
119
|
this.d_loading = newValue;
|
|
97
120
|
},
|
|
98
|
-
items(newValue,
|
|
99
|
-
if (!
|
|
121
|
+
items(newValue, oldValue) {
|
|
122
|
+
if (!oldValue || oldValue.length !== (newValue || []).length) {
|
|
100
123
|
this.init();
|
|
101
124
|
}
|
|
125
|
+
},
|
|
126
|
+
orientation() {
|
|
127
|
+
this.lastScrollPos = this.isBoth() ? { top: 0, left: 0 } : 0;
|
|
102
128
|
}
|
|
103
129
|
},
|
|
104
130
|
methods: {
|
|
105
131
|
init() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
this.setSize();
|
|
133
|
+
this.calculateOptions();
|
|
134
|
+
this.setSpacerSize();
|
|
135
|
+
},
|
|
136
|
+
isVertical() {
|
|
137
|
+
return this.orientation === 'vertical';
|
|
138
|
+
},
|
|
139
|
+
isHorizontal() {
|
|
140
|
+
return this.orientation === 'horizontal';
|
|
141
|
+
},
|
|
142
|
+
isBoth() {
|
|
143
|
+
return this.orientation === 'both';
|
|
144
|
+
},
|
|
145
|
+
scrollTo(options) {
|
|
146
|
+
this.element && this.element.scrollTo(options);
|
|
147
|
+
},
|
|
148
|
+
scrollToIndex(index, behavior = 'auto') {
|
|
149
|
+
const both = this.isBoth();
|
|
150
|
+
const horizontal = this.isHorizontal();
|
|
151
|
+
const contentPos = this.getContentPosition();
|
|
152
|
+
const calculateFirst = (_index = 0, _numT) => (_index <= _numT ? 0 : _index);
|
|
153
|
+
const calculateCoord = (_first, _size, _cpos) => (_first * _size) + _cpos;
|
|
154
|
+
const scrollTo = (left = 0, top = 0) => this.scrollTo({ left, top, behavior });
|
|
155
|
+
|
|
156
|
+
if (both) {
|
|
157
|
+
const newFirst = { rows: calculateFirst(index[0], this.d_numToleratedItems[0]), cols: calculateFirst(index[1], this.d_numToleratedItems[1]) };
|
|
158
|
+
if (newFirst.rows !== this.first.rows || newFirst.cols !== this.first.cols) {
|
|
159
|
+
scrollTo(calculateCoord(newFirst.cols, this.itemSize[1], contentPos.left), calculateCoord(newFirst.rows, this.itemSize[0], contentPos.top))
|
|
160
|
+
this.first = newFirst;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
const newFirst = calculateFirst(index, this.d_numToleratedItems);
|
|
165
|
+
|
|
166
|
+
if (newFirst !== this.first) {
|
|
167
|
+
horizontal ? scrollTo(calculateCoord(newFirst, this.itemSize, contentPos.left), 0) : scrollTo(0, calculateCoord(newFirst, this.itemSize, contentPos.top));
|
|
168
|
+
this.first = newFirst;
|
|
169
|
+
}
|
|
110
170
|
}
|
|
111
171
|
},
|
|
112
|
-
|
|
113
|
-
|
|
172
|
+
scrollInView(index, to, behavior = 'auto') {
|
|
173
|
+
if (to) {
|
|
174
|
+
const both = this.isBoth();
|
|
175
|
+
const horizontal = this.isHorizontal();
|
|
176
|
+
const { first, viewport } = this.getRenderedRange();
|
|
177
|
+
const scrollTo = (left = 0, top = 0) => this.scrollTo({ left, top, behavior });
|
|
178
|
+
const isToStart = to === 'to-start';
|
|
179
|
+
const isToEnd = to === 'to-end';
|
|
180
|
+
|
|
181
|
+
if (isToStart) {
|
|
182
|
+
if (both) {
|
|
183
|
+
if (viewport.first.rows - first.rows > index[0]) {
|
|
184
|
+
scrollTo(viewport.first.cols * this.itemSize[1], (viewport.first.rows - 1) * this.itemSize[0]);
|
|
185
|
+
}
|
|
186
|
+
else if (viewport.first.cols - first.cols > index[1]) {
|
|
187
|
+
scrollTo((viewport.first.cols - 1) * this.itemSize[1], viewport.first.rows * this.itemSize[0]);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
if (viewport.first - first > index) {
|
|
192
|
+
const pos = (viewport.first - 1) * this.itemSize;
|
|
193
|
+
horizontal ? scrollTo(pos, 0) : scrollTo(0, pos);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (isToEnd) {
|
|
198
|
+
if (both) {
|
|
199
|
+
if (viewport.last.rows - first.rows <= index[0] + 1) {
|
|
200
|
+
scrollTo(viewport.first.cols * this.itemSize[1], (viewport.first.rows + 1) * this.itemSize[0]);
|
|
201
|
+
}
|
|
202
|
+
else if (viewport.last.cols - first.cols <= index[1] + 1) {
|
|
203
|
+
scrollTo((viewport.first.cols + 1) * this.itemSize[1], viewport.first.rows * this.itemSize[0]);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
if (viewport.last - first <= index + 1) {
|
|
208
|
+
const pos = (viewport.first + 1) * this.itemSize;
|
|
209
|
+
horizontal ? scrollTo(pos, 0) : scrollTo(0, pos);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this.scrollToIndex(index, behavior);
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
getRenderedRange() {
|
|
219
|
+
const calculateFirstInViewport = (_pos, _size) => Math.floor(_pos / (_size || _pos));
|
|
220
|
+
|
|
221
|
+
let firstInViewport = this.first;
|
|
222
|
+
let lastInViewport = 0;
|
|
223
|
+
|
|
224
|
+
if (this.element) {
|
|
225
|
+
const both = this.isBoth();
|
|
226
|
+
const horizontal = this.isHorizontal();
|
|
227
|
+
const scrollTop = this.element.scrollTop;
|
|
228
|
+
const scrollLeft = this.element.scrollLeft;
|
|
229
|
+
|
|
230
|
+
if (both) {
|
|
231
|
+
firstInViewport = { rows: calculateFirstInViewport(scrollTop, this.itemSize[0]), cols: calculateFirstInViewport(scrollLeft, this.itemSize[1]) };
|
|
232
|
+
lastInViewport = { rows: firstInViewport.rows + this.numItemsInViewport.rows, cols: firstInViewport.cols + this.numItemsInViewport.cols };
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const scrollPos = horizontal ? scrollLeft : scrollTop;
|
|
236
|
+
firstInViewport = calculateFirstInViewport(scrollPos, this.itemSize);
|
|
237
|
+
lastInViewport = firstInViewport + this.numItemsInViewport;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return {
|
|
242
|
+
first: this.first,
|
|
243
|
+
last: this.last,
|
|
244
|
+
viewport: {
|
|
245
|
+
first: firstInViewport,
|
|
246
|
+
last: lastInViewport
|
|
247
|
+
}
|
|
248
|
+
};
|
|
114
249
|
},
|
|
115
250
|
calculateOptions() {
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
const contentWidth = this.element ? this.element.offsetWidth - contentPadding.left : 0;
|
|
122
|
-
const contentHeight = this.element ? this.element.offsetHeight - contentPadding.top : 0;
|
|
251
|
+
const both = this.isBoth();
|
|
252
|
+
const horizontal = this.isHorizontal();
|
|
253
|
+
const contentPos = this.getContentPosition();
|
|
254
|
+
const contentWidth = this.element ? this.element.offsetWidth - contentPos.left : 0;
|
|
255
|
+
const contentHeight = this.element ? this.element.offsetHeight - contentPos.top : 0;
|
|
123
256
|
const calculateNumItemsInViewport = (_contentSize, _itemSize) => Math.ceil(_contentSize / (_itemSize || _contentSize));
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
calculateNumItemsInViewport(
|
|
257
|
+
const calculateNumToleratedItems = (_numItems) => Math.ceil(_numItems / 2);
|
|
258
|
+
const numItemsInViewport = both ?
|
|
259
|
+
{ rows: calculateNumItemsInViewport(contentHeight, this.itemSize[0]), cols: calculateNumItemsInViewport(contentWidth, this.itemSize[1]) } :
|
|
260
|
+
calculateNumItemsInViewport((horizontal ? contentWidth : contentHeight), this.itemSize);
|
|
127
261
|
|
|
128
|
-
let numToleratedItems = this.d_numToleratedItems ||
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
262
|
+
let numToleratedItems = this.d_numToleratedItems || (both ?
|
|
263
|
+
[calculateNumToleratedItems(numItemsInViewport.rows), calculateNumToleratedItems(numItemsInViewport.cols)] :
|
|
264
|
+
calculateNumToleratedItems(numItemsInViewport));
|
|
265
|
+
|
|
266
|
+
const calculateLast = (_first, _num, _numT, _isCols) => this.getLast(_first + _num + ((_first < _numT ? 2 : 3) * _numT), _isCols);
|
|
267
|
+
const last = both ?
|
|
268
|
+
{ rows: calculateLast(this.first.rows, numItemsInViewport.rows, numToleratedItems[0]), cols: calculateLast(this.first.cols, numItemsInViewport.cols, numToleratedItems[1], true) } :
|
|
269
|
+
calculateLast(this.first, numItemsInViewport, numToleratedItems);
|
|
133
270
|
|
|
134
|
-
this.d_numToleratedItems = numToleratedItems;
|
|
135
|
-
this.$emit('update:numToleratedItems', this.d_numToleratedItems);
|
|
136
271
|
this.last = last;
|
|
137
272
|
this.numItemsInViewport = numItemsInViewport;
|
|
273
|
+
this.d_numToleratedItems = numToleratedItems;
|
|
274
|
+
this.$emit('update:numToleratedItems', this.d_numToleratedItems);
|
|
138
275
|
|
|
139
276
|
if (this.showLoader) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
else {
|
|
144
|
-
this.loaderArr = Array.from({ length: 1});
|
|
145
|
-
}
|
|
277
|
+
this.loaderArr = both ?
|
|
278
|
+
Array.from({ length: numItemsInViewport.rows }).map(() => Array.from({ length: numItemsInViewport.cols })) :
|
|
279
|
+
Array.from({ length: numItemsInViewport });
|
|
146
280
|
}
|
|
147
281
|
|
|
148
282
|
if (this.lazy) {
|
|
149
|
-
this.$emit('lazy-load', { first, last });
|
|
283
|
+
this.$emit('lazy-load', { first: this.first, last });
|
|
150
284
|
}
|
|
151
285
|
},
|
|
152
|
-
|
|
286
|
+
getLast(last = 0, isCols) {
|
|
287
|
+
if (this.items) {
|
|
288
|
+
return Math.min((isCols ? (this.columns || this.items[0]).length : this.items.length), last);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return 0;
|
|
292
|
+
},
|
|
293
|
+
getContentPosition() {
|
|
153
294
|
if (this.content) {
|
|
154
295
|
const style = getComputedStyle(this.content);
|
|
155
|
-
const left = parseInt(
|
|
156
|
-
const right = parseInt(
|
|
157
|
-
const top = parseInt(
|
|
158
|
-
const bottom = parseInt(
|
|
296
|
+
const left = parseInt(style.paddingLeft, 10) + Math.max(parseInt(style.left, 10), 0);
|
|
297
|
+
const right = parseInt(style.paddingRight, 10) + Math.max(parseInt(style.right, 10), 0);
|
|
298
|
+
const top = parseInt(style.paddingTop, 10) + Math.max(parseInt(style.top, 10), 0);
|
|
299
|
+
const bottom = parseInt(style.paddingBottom, 10) + Math.max(parseInt(style.bottom, 10), 0);
|
|
159
300
|
|
|
160
301
|
return { left, right, top, bottom, x: left + right, y: top + bottom };
|
|
161
302
|
}
|
|
@@ -164,126 +305,125 @@ export default {
|
|
|
164
305
|
},
|
|
165
306
|
setSize() {
|
|
166
307
|
if (this.element) {
|
|
167
|
-
const
|
|
168
|
-
const
|
|
308
|
+
const both = this.isBoth();
|
|
309
|
+
const horizontal = this.isHorizontal();
|
|
169
310
|
const parentElement = this.element.parentElement;
|
|
170
311
|
const width = this.scrollWidth || `${(this.element.offsetWidth || parentElement.offsetWidth)}px`;
|
|
171
312
|
const height = this.scrollHeight || `${(this.element.offsetHeight || parentElement.offsetHeight)}px`;
|
|
172
313
|
const setProp = (_name, _value) => this.element.style[_name] = _value;
|
|
173
314
|
|
|
174
|
-
if (
|
|
315
|
+
if (both || horizontal) {
|
|
175
316
|
setProp('height', height);
|
|
176
317
|
setProp('width', width);
|
|
177
318
|
}
|
|
178
319
|
else {
|
|
179
|
-
|
|
320
|
+
setProp('height', height);
|
|
180
321
|
}
|
|
181
322
|
}
|
|
182
323
|
},
|
|
183
324
|
setSpacerSize() {
|
|
184
325
|
const items = this.items;
|
|
185
326
|
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const setProp = (_name, _value, _size, _padding = 0) => this.spacer.style[_name] = (((_value || []).length * _size) + _padding) + 'px';
|
|
327
|
+
if (items) {
|
|
328
|
+
const both = this.isBoth();
|
|
329
|
+
const horizontal = this.isHorizontal();
|
|
330
|
+
const contentPos = this.getContentPosition();
|
|
331
|
+
const setProp = (_name, _value, _size, _cpos = 0) => this.spacerStyle = { ...this.spacerStyle, ...{ [`${_name}`]: (((_value || []).length * _size) + _cpos) + 'px' } };
|
|
192
332
|
|
|
193
|
-
if (
|
|
194
|
-
setProp('height', items
|
|
195
|
-
setProp('width', items[1], itemSize[1],
|
|
333
|
+
if (both) {
|
|
334
|
+
setProp('height', items, this.itemSize[0], contentPos.y);
|
|
335
|
+
setProp('width', (this.columns || items[1]), this.itemSize[1], contentPos.x);
|
|
196
336
|
}
|
|
197
337
|
else {
|
|
198
|
-
|
|
338
|
+
horizontal ? setProp('width', (this.columns || items), this.itemSize, contentPos.x) : setProp('height', items, this.itemSize, contentPos.y);
|
|
199
339
|
}
|
|
200
340
|
}
|
|
201
341
|
},
|
|
202
342
|
setContentPosition(pos) {
|
|
203
343
|
if (this.content) {
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const content = this.content;
|
|
344
|
+
const both = this.isBoth();
|
|
345
|
+
const horizontal = this.isHorizontal();
|
|
207
346
|
const first = pos ? pos.first : this.first;
|
|
208
|
-
const itemSize = this.itemSize;
|
|
209
347
|
const calculateTranslateVal = (_first, _size) => (_first * _size);
|
|
210
|
-
const setTransform = (_x = 0, _y = 0) =>
|
|
348
|
+
const setTransform = (_x = 0, _y = 0) => {
|
|
349
|
+
this.contentStyle = { ...this.contentStyle, ...{ transform: `translate3d(${_x}px, ${_y}px, 0)` } };
|
|
350
|
+
};
|
|
211
351
|
|
|
212
|
-
if (
|
|
213
|
-
setTransform(calculateTranslateVal(first.cols, itemSize[1]), calculateTranslateVal(first.rows, itemSize[0]));
|
|
352
|
+
if (both) {
|
|
353
|
+
setTransform(calculateTranslateVal(first.cols, this.itemSize[1]), calculateTranslateVal(first.rows, this.itemSize[0]));
|
|
214
354
|
}
|
|
215
355
|
else {
|
|
216
|
-
const translateVal = calculateTranslateVal(first, itemSize);
|
|
217
|
-
|
|
356
|
+
const translateVal = calculateTranslateVal(first, this.itemSize);
|
|
357
|
+
horizontal ? setTransform(translateVal, 0) : setTransform(0, translateVal);
|
|
218
358
|
}
|
|
219
359
|
}
|
|
220
360
|
},
|
|
221
361
|
onScrollPositionChange(event) {
|
|
222
362
|
const target = event.target;
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
const calculateScrollPos = (_pos, _padding) => _pos ? (_pos > _padding ? _pos - _padding : _pos) : 0;
|
|
363
|
+
const both = this.isBoth();
|
|
364
|
+
const horizontal = this.isHorizontal();
|
|
365
|
+
const contentPos = this.getContentPosition();
|
|
366
|
+
const calculateScrollPos = (_pos, _cpos) => _pos ? (_pos > _cpos ? _pos - _cpos : _pos) : 0;
|
|
228
367
|
const calculateCurrentIndex = (_pos, _size) => Math.floor(_pos / (_size || _pos));
|
|
229
|
-
const calculateTriggerIndex = (_currentIndex, _first, _last, _num, _isScrollDownOrRight) => {
|
|
230
|
-
return (_currentIndex <=
|
|
368
|
+
const calculateTriggerIndex = (_currentIndex, _first, _last, _num, _numT, _isScrollDownOrRight) => {
|
|
369
|
+
return (_currentIndex <= _numT ? _numT : (_isScrollDownOrRight ? (_last - _num - _numT) : (_first + _numT - 1)))
|
|
231
370
|
};
|
|
232
|
-
const calculateFirst = (_currentIndex, _triggerIndex, _first, _last, _num, _isScrollDownOrRight) => {
|
|
233
|
-
if (_currentIndex <=
|
|
371
|
+
const calculateFirst = (_currentIndex, _triggerIndex, _first, _last, _num, _numT, _isScrollDownOrRight) => {
|
|
372
|
+
if (_currentIndex <= _numT)
|
|
234
373
|
return 0;
|
|
235
374
|
else
|
|
236
|
-
return _isScrollDownOrRight ?
|
|
237
|
-
|
|
238
|
-
|
|
375
|
+
return Math.max(0, _isScrollDownOrRight ?
|
|
376
|
+
(_currentIndex < _triggerIndex ? _first : _currentIndex - _numT) :
|
|
377
|
+
(_currentIndex > _triggerIndex ? _first : _currentIndex - (2 * _numT)));
|
|
239
378
|
};
|
|
240
|
-
const calculateLast = (_currentIndex, _first, _last, _num, _isCols) => {
|
|
241
|
-
let lastValue = _first + _num + (2 *
|
|
379
|
+
const calculateLast = (_currentIndex, _first, _last, _num, _numT, _isCols) => {
|
|
380
|
+
let lastValue = _first + _num + (2 * _numT);
|
|
242
381
|
|
|
243
|
-
if (_currentIndex >=
|
|
244
|
-
lastValue += (
|
|
382
|
+
if (_currentIndex >= _numT) {
|
|
383
|
+
lastValue += (_numT + 1);
|
|
245
384
|
}
|
|
246
385
|
|
|
247
386
|
return this.getLast(lastValue, _isCols);
|
|
248
387
|
};
|
|
249
388
|
|
|
250
|
-
const scrollTop = calculateScrollPos(target.scrollTop,
|
|
251
|
-
const scrollLeft = calculateScrollPos(target.scrollLeft,
|
|
389
|
+
const scrollTop = calculateScrollPos(target.scrollTop, contentPos.top);
|
|
390
|
+
const scrollLeft = calculateScrollPos(target.scrollLeft, contentPos.left);
|
|
252
391
|
|
|
253
392
|
let newFirst = 0;
|
|
254
393
|
let newLast = this.last;
|
|
255
394
|
let isRangeChanged = false;
|
|
256
395
|
|
|
257
|
-
if (
|
|
396
|
+
if (both) {
|
|
258
397
|
const isScrollDown = this.lastScrollPos.top <= scrollTop;
|
|
259
398
|
const isScrollRight = this.lastScrollPos.left <= scrollLeft;
|
|
260
|
-
const currentIndex = { rows: calculateCurrentIndex(scrollTop, itemSize[0]), cols: calculateCurrentIndex(scrollLeft, itemSize[1]) };
|
|
399
|
+
const currentIndex = { rows: calculateCurrentIndex(scrollTop, this.itemSize[0]), cols: calculateCurrentIndex(scrollLeft, this.itemSize[1]) };
|
|
261
400
|
const triggerIndex = {
|
|
262
|
-
rows: calculateTriggerIndex(currentIndex.rows, this.first.rows, this.last.rows, this.numItemsInViewport.rows, isScrollDown),
|
|
263
|
-
cols: calculateTriggerIndex(currentIndex.cols, this.first.cols, this.last.cols, this.numItemsInViewport.cols, isScrollRight)
|
|
401
|
+
rows: calculateTriggerIndex(currentIndex.rows, this.first.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0], isScrollDown),
|
|
402
|
+
cols: calculateTriggerIndex(currentIndex.cols, this.first.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], isScrollRight)
|
|
264
403
|
};
|
|
265
404
|
|
|
266
405
|
newFirst = {
|
|
267
|
-
rows: calculateFirst(currentIndex.rows, triggerIndex.rows, this.first.rows, this.last.rows, this.numItemsInViewport.rows, isScrollDown),
|
|
268
|
-
cols: calculateFirst(currentIndex.cols, triggerIndex.cols, this.first.cols, this.last.cols, this.numItemsInViewport.cols, isScrollRight)
|
|
406
|
+
rows: calculateFirst(currentIndex.rows, triggerIndex.rows, this.first.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0], isScrollDown),
|
|
407
|
+
cols: calculateFirst(currentIndex.cols, triggerIndex.cols, this.first.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], isScrollRight)
|
|
269
408
|
};
|
|
270
409
|
newLast = {
|
|
271
|
-
rows: calculateLast(currentIndex.rows, newFirst.rows, this.last.rows, this.numItemsInViewport.rows),
|
|
272
|
-
cols: calculateLast(currentIndex.cols, newFirst.cols, this.last.cols, this.numItemsInViewport.cols, true)
|
|
410
|
+
rows: calculateLast(currentIndex.rows, newFirst.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0]),
|
|
411
|
+
cols: calculateLast(currentIndex.cols, newFirst.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], true)
|
|
273
412
|
};
|
|
274
|
-
|
|
413
|
+
|
|
414
|
+
isRangeChanged = (newFirst.rows !== this.first.rows && newLast.rows !== this.last.rows) || (newFirst.cols !== this.first.cols && newLast.cols !== this.last.cols);
|
|
275
415
|
|
|
276
416
|
this.lastScrollPos = { top: scrollTop, left: scrollLeft };
|
|
277
417
|
}
|
|
278
418
|
else {
|
|
279
|
-
const scrollPos =
|
|
419
|
+
const scrollPos = horizontal ? scrollLeft : scrollTop;
|
|
280
420
|
const isScrollDownOrRight = this.lastScrollPos <= scrollPos;
|
|
281
|
-
const currentIndex = calculateCurrentIndex(scrollPos, itemSize);
|
|
282
|
-
const triggerIndex = calculateTriggerIndex(currentIndex, this.first, this.last, this.numItemsInViewport, isScrollDownOrRight);
|
|
421
|
+
const currentIndex = calculateCurrentIndex(scrollPos, this.itemSize);
|
|
422
|
+
const triggerIndex = calculateTriggerIndex(currentIndex, this.first, this.last, this.numItemsInViewport, this.d_numToleratedItems, isScrollDownOrRight);
|
|
283
423
|
|
|
284
|
-
newFirst = calculateFirst(currentIndex, triggerIndex, this.first, this.last, this.numItemsInViewport, isScrollDownOrRight);
|
|
285
|
-
newLast = calculateLast(currentIndex, newFirst, this.last, this.numItemsInViewport);
|
|
286
|
-
isRangeChanged = newFirst !== this.first
|
|
424
|
+
newFirst = calculateFirst(currentIndex, triggerIndex, this.first, this.last, this.numItemsInViewport, this.d_numToleratedItems, isScrollDownOrRight);
|
|
425
|
+
newLast = calculateLast(currentIndex, newFirst, this.last, this.numItemsInViewport, this.d_numToleratedItems);
|
|
426
|
+
isRangeChanged = newFirst !== this.first && newLast !== this.last;
|
|
287
427
|
|
|
288
428
|
this.lastScrollPos = scrollPos;
|
|
289
429
|
}
|
|
@@ -302,27 +442,27 @@ export default {
|
|
|
302
442
|
|
|
303
443
|
this.setContentPosition(newState);
|
|
304
444
|
|
|
305
|
-
if (this.lazy) {
|
|
306
|
-
this.$emit('lazy-load', { first, last });
|
|
307
|
-
}
|
|
308
445
|
this.first = first;
|
|
309
446
|
this.last = last;
|
|
310
447
|
|
|
311
|
-
this.$emit('scroll-index-change',
|
|
448
|
+
this.$emit('scroll-index-change', newState);
|
|
449
|
+
|
|
450
|
+
if (this.lazy) {
|
|
451
|
+
this.$emit('lazy-load', newState);
|
|
452
|
+
}
|
|
312
453
|
}
|
|
313
454
|
},
|
|
314
455
|
onScroll(event) {
|
|
315
|
-
|
|
456
|
+
this.$emit('scroll', event);
|
|
457
|
+
|
|
458
|
+
if (this.delay) {
|
|
316
459
|
if (this.scrollTimeout) {
|
|
317
460
|
clearTimeout(this.scrollTimeout);
|
|
318
461
|
}
|
|
319
462
|
|
|
320
463
|
if (!this.d_loading && this.showLoader) {
|
|
321
464
|
const { isRangeChanged: changed } = this.onScrollPositionChange(event);
|
|
322
|
-
|
|
323
|
-
if (changed) {
|
|
324
|
-
this.d_loading = true;
|
|
325
|
-
}
|
|
465
|
+
changed && (this.d_loading = true);
|
|
326
466
|
}
|
|
327
467
|
|
|
328
468
|
this.scrollTimeout = setTimeout(() => {
|
|
@@ -338,8 +478,8 @@ export default {
|
|
|
338
478
|
}
|
|
339
479
|
},
|
|
340
480
|
getOptions(renderedIndex) {
|
|
341
|
-
|
|
342
|
-
|
|
481
|
+
const count = (this.items || []).length;
|
|
482
|
+
const index = this.isBoth() ? this.first.rows + renderedIndex : this.first + renderedIndex;
|
|
343
483
|
return {
|
|
344
484
|
index,
|
|
345
485
|
count,
|
|
@@ -349,139 +489,23 @@ export default {
|
|
|
349
489
|
odd: index % 2 !== 0
|
|
350
490
|
};
|
|
351
491
|
},
|
|
352
|
-
getLoaderOptions(index) {
|
|
492
|
+
getLoaderOptions(index, extOptions) {
|
|
353
493
|
let count = this.loaderArr.length;
|
|
354
494
|
return {
|
|
355
|
-
|
|
495
|
+
index,
|
|
496
|
+
count,
|
|
356
497
|
first: index === 0,
|
|
357
498
|
last: index === (count - 1),
|
|
358
499
|
even: index % 2 === 0,
|
|
359
|
-
odd: index % 2 !== 0
|
|
360
|
-
|
|
361
|
-
},
|
|
362
|
-
isHorizontal() {
|
|
363
|
-
return this.orientation === 'horizontal';
|
|
364
|
-
},
|
|
365
|
-
isBoth() {
|
|
366
|
-
return this.orientation === 'both';
|
|
367
|
-
},
|
|
368
|
-
scrollTo(options) {
|
|
369
|
-
if (this.element) {
|
|
370
|
-
this.element.scrollTo(options);
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
scrollToIndex(index, behavior = 'auto') {
|
|
374
|
-
const isBoth = this.isBoth();
|
|
375
|
-
const isHorizontal = this.isHorizontal();
|
|
376
|
-
const itemSize = this.itemSize;
|
|
377
|
-
const contentPadding = this.getContentPadding();
|
|
378
|
-
const calculateFirst = (_index = 0) => (_index <= this.d_numToleratedItems ? 0 : _index);
|
|
379
|
-
const calculateCoord = (_first, _size, _padding) => (_first * _size) + _padding;
|
|
380
|
-
const scrollTo = (left = 0, top = 0) => this.scrollTo({ left, top, behavior });
|
|
381
|
-
|
|
382
|
-
if (isBoth) {
|
|
383
|
-
const newFirst = { rows: calculateFirst(index[0]), cols: calculateFirst(index[1]) };
|
|
384
|
-
if (newFirst.rows !== this.first.rows || newFirst.cols !== this.first.cols)
|
|
385
|
-
scrollTo(calculateCoord(newFirst.cols, itemSize[1], contentPadding.left),calculateCoord(newFirst.rows, itemSize[0], contentPadding.top));
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
const newFirst = calculateFirst(index);
|
|
389
|
-
|
|
390
|
-
if (newFirst !== this.first) {
|
|
391
|
-
isHorizontal ? scrollTo(calculateCoord(newFirst, itemSize, contentPadding.left), 0) : scrollTo(0, calculateCoord(newFirst, itemSize, contentPadding.top));
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
this.first = newFirst;
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
scrollInView(index, to, behavior = 'auto') {
|
|
398
|
-
if (to) {
|
|
399
|
-
const isBoth = this.isBoth();
|
|
400
|
-
const isHorizontal = this.isHorizontal();
|
|
401
|
-
const { first, viewport } = this.getRenderedRange();
|
|
402
|
-
const itemSize = this.itemSize;
|
|
403
|
-
const scrollTo = (left = 0, top = 0) => this.scrollTo({ left, top, behavior });
|
|
404
|
-
const isToStart = to === 'to-start';
|
|
405
|
-
const isToEnd = to === 'to-end';
|
|
406
|
-
|
|
407
|
-
if (isToStart) {
|
|
408
|
-
if (isBoth) {
|
|
409
|
-
if (viewport.first.rows - first.rows > index[0]) {
|
|
410
|
-
scrollTo(viewport.first.cols * itemSize[1], (viewport.first.rows - 1) * itemSize[0]);
|
|
411
|
-
}
|
|
412
|
-
else if (viewport.first.cols - first.cols > index[1]) {
|
|
413
|
-
scrollTo((viewport.first.cols - 1) * itemSize[1], viewport.first.rows * itemSize[0]);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
if (viewport.first - first > index) {
|
|
418
|
-
const pos = (viewport.first - 1) * itemSize;
|
|
419
|
-
isHorizontal ? scrollTo(pos, 0) : scrollTo(0, pos);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
else if (isToEnd) {
|
|
424
|
-
if (isBoth) {
|
|
425
|
-
if (viewport.last.rows - first.rows <= index[0] + 1) {
|
|
426
|
-
scrollTo(viewport.first.cols * itemSize[1], (viewport.first.rows + 1) * itemSize[0]);
|
|
427
|
-
}
|
|
428
|
-
else if (viewport.last.cols - first.cols <= index[1] + 1) {
|
|
429
|
-
scrollTo((viewport.first.cols + 1) * itemSize[1], viewport.first.rows * itemSize[0]);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
if (viewport.last - first <= index + 1) {
|
|
434
|
-
const pos = (viewport.first + 1) * itemSize;
|
|
435
|
-
isHorizontal ? scrollTo(pos, 0) : scrollTo(0, pos);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
else {
|
|
441
|
-
this.scrollToIndex(index, behavior);
|
|
500
|
+
odd: index % 2 !== 0,
|
|
501
|
+
...extOptions
|
|
442
502
|
}
|
|
443
503
|
},
|
|
444
|
-
getRenderedRange() {
|
|
445
|
-
const isBoth = this.isBoth();
|
|
446
|
-
const isHorizontal = this.isHorizontal();
|
|
447
|
-
const itemSize = this.itemSize;
|
|
448
|
-
const calculateFirstInViewport = (_pos, _size) => Math.floor(_pos / (_size || _pos));
|
|
449
|
-
|
|
450
|
-
let firstInViewport = this.first;
|
|
451
|
-
let lastInViewport = 0;
|
|
452
|
-
|
|
453
|
-
if (this.element) {
|
|
454
|
-
const scrollTop = this.element.scrollTop;
|
|
455
|
-
const scrollLeft = this.element.scrollLeft;
|
|
456
|
-
|
|
457
|
-
if (isBoth) {
|
|
458
|
-
firstInViewport = { rows: calculateFirstInViewport(scrollTop, itemSize[0]), cols: calculateFirstInViewport(scrollLeft, itemSize[1]) };
|
|
459
|
-
lastInViewport = { rows: firstInViewport.rows + this.numItemsInViewport.rows, cols: firstInViewport.cols + this.numItemsInViewport.cols };
|
|
460
|
-
}
|
|
461
|
-
else {
|
|
462
|
-
const scrollPos = isHorizontal ? scrollLeft : scrollTop;
|
|
463
|
-
firstInViewport = calculateFirstInViewport(scrollPos, itemSize);
|
|
464
|
-
lastInViewport = firstInViewport + this.numItemsInViewport;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
return {
|
|
469
|
-
first: this.first,
|
|
470
|
-
last: this.last,
|
|
471
|
-
viewport: {
|
|
472
|
-
first: firstInViewport,
|
|
473
|
-
last: lastInViewport
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
},
|
|
477
504
|
elementRef(el) {
|
|
478
505
|
this.element = el;
|
|
479
506
|
},
|
|
480
507
|
contentRef(el) {
|
|
481
508
|
this.content = el;
|
|
482
|
-
},
|
|
483
|
-
spacerRef(el) {
|
|
484
|
-
this.spacer = el;
|
|
485
509
|
}
|
|
486
510
|
},
|
|
487
511
|
computed: {
|
|
@@ -491,6 +515,11 @@ export default {
|
|
|
491
515
|
'p-horizontal-scroll': this.isHorizontal()
|
|
492
516
|
}, this.class];
|
|
493
517
|
},
|
|
518
|
+
contentClass() {
|
|
519
|
+
return ['p-virtualscroller-content', {
|
|
520
|
+
'p-virtualscroller-loading': this.d_loading
|
|
521
|
+
}];
|
|
522
|
+
},
|
|
494
523
|
loaderClass() {
|
|
495
524
|
return ['p-virtualscroller-loader', {
|
|
496
525
|
'p-component-overlay': !this.$slots.loader
|
|
@@ -499,22 +528,33 @@ export default {
|
|
|
499
528
|
loadedItems() {
|
|
500
529
|
const items = this.items;
|
|
501
530
|
if (items && !this.d_loading) {
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
if (isBoth) {
|
|
505
|
-
return items.slice(this.first.rows, this.last.rows).map((item) => {
|
|
506
|
-
const items = item.slice(this.first.cols, this.last.cols);
|
|
507
|
-
return items;
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
else {
|
|
511
|
-
return items.slice(this.first, this.last).map((item) => {
|
|
512
|
-
return item;
|
|
513
|
-
});
|
|
531
|
+
if (this.isBoth()) {
|
|
532
|
+
return items.slice(this.first.rows, this.last.rows).map(item => this.columns ? item : item.slice(this.first.cols, this.last.cols));
|
|
514
533
|
}
|
|
534
|
+
else if (this.isHorizontal() && this.columns)
|
|
535
|
+
return items;
|
|
536
|
+
else
|
|
537
|
+
return items.slice(this.first, this.last);
|
|
515
538
|
}
|
|
516
539
|
|
|
517
540
|
return [];
|
|
541
|
+
},
|
|
542
|
+
loadedRows() {
|
|
543
|
+
return this.d_loading ? (this.loaderDisabled ? this.loaderArr : []) : this.loadedItems;
|
|
544
|
+
},
|
|
545
|
+
loadedColumns() {
|
|
546
|
+
if (this.columns) {
|
|
547
|
+
const both = this.isBoth();
|
|
548
|
+
const horizontal = this.isHorizontal();
|
|
549
|
+
|
|
550
|
+
if (both || horizontal) {
|
|
551
|
+
return this.d_loading && this.loaderDisabled ?
|
|
552
|
+
(both ? this.loaderArr[0] : this.loaderArr):
|
|
553
|
+
this.columns.slice((both ? this.first.cols : this.first), (both ? this.last.cols : this.last));
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
return this.columns;
|
|
518
558
|
}
|
|
519
559
|
}
|
|
520
560
|
}
|
|
@@ -527,6 +567,7 @@ export default {
|
|
|
527
567
|
contain: strict;
|
|
528
568
|
transform: translateZ(0);
|
|
529
569
|
will-change: scroll-position;
|
|
570
|
+
outline: 0 none;
|
|
530
571
|
}
|
|
531
572
|
|
|
532
573
|
.p-virtualscroller-content {
|