primevue 3.23.0 → 3.24.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/LICENSE.md +1 -1
- package/README.md +12 -12
- package/accordion/Accordion.d.ts +53 -21
- package/accordiontab/AccordionTab.d.ts +33 -12
- package/autocomplete/AutoComplete.d.ts +111 -84
- package/avatar/Avatar.d.ts +38 -25
- package/avatar/Avatar.vue +1 -1
- package/avatar/avatar.cjs.js +2 -1
- package/avatar/avatar.cjs.min.js +1 -1
- package/avatar/avatar.esm.js +2 -1
- package/avatar/avatar.esm.min.js +1 -1
- package/avatar/avatar.js +2 -1
- package/avatar/avatar.min.js +1 -1
- package/avatargroup/AvatarGroup.d.ts +30 -14
- package/badge/Badge.d.ts +34 -20
- package/badge/Badge.vue +16 -5
- package/badge/badge.cjs.js +15 -5
- package/badge/badge.cjs.min.js +1 -1
- package/badge/badge.esm.js +15 -5
- package/badge/badge.esm.min.js +1 -1
- package/badge/badge.js +16 -7
- package/badge/badge.min.js +1 -1
- package/badgedirective/BadgeDirective.d.ts +60 -1
- package/blockui/BlockUI.d.ts +36 -16
- package/breadcrumb/Breadcrumb.d.ts +37 -20
- package/button/Button.d.ts +74 -17
- package/button/Button.vue +51 -8
- package/button/button.cjs.js +51 -8
- package/button/button.cjs.min.js +1 -1
- package/button/button.esm.js +51 -8
- package/button/button.esm.min.js +1 -1
- package/button/button.js +51 -8
- package/button/button.min.js +1 -1
- package/calendar/Calendar.d.ts +112 -77
- package/card/Card.d.ts +35 -15
- package/carousel/Carousel.d.ts +47 -29
- package/cascadeselect/CascadeSelect.d.ts +70 -59
- package/chart/Chart.d.ts +41 -23
- package/checkbox/Checkbox.d.ts +39 -15
- package/checkbox/Checkbox.vue +1 -1
- package/checkbox/checkbox.cjs.js +1 -1
- package/checkbox/checkbox.cjs.min.js +1 -1
- package/checkbox/checkbox.esm.js +1 -1
- package/checkbox/checkbox.esm.min.js +1 -1
- package/checkbox/checkbox.js +1 -1
- package/checkbox/checkbox.min.js +1 -1
- package/chip/Chip.d.ts +35 -14
- package/chips/Chips.d.ts +45 -20
- package/colorpicker/ColorPicker.d.ts +46 -28
- package/column/Column.d.ts +81 -65
- package/columngroup/ColumnGroup.d.ts +29 -13
- package/config/config.cjs.js +20 -1
- package/config/config.cjs.min.js +1 -1
- package/config/config.esm.js +20 -1
- package/config/config.esm.min.js +1 -1
- package/config/config.js +20 -1
- package/config/config.min.js +1 -1
- package/confirmationoptions/ConfirmationOptions.d.ts +15 -6
- package/confirmationservice/ConfirmationService.d.ts +11 -0
- package/confirmdialog/ConfirmDialog.d.ts +35 -17
- package/confirmpopup/ConfirmPopup.d.ts +32 -17
- package/contextmenu/ContextMenu.d.ts +51 -35
- package/core/core.js +339 -104
- package/core/core.min.js +6 -6
- package/datatable/DataTable.d.ts +248 -205
- package/datatable/DataTable.vue +72 -111
- package/datatable/TableBody.vue +3 -17
- package/datatable/datatable.cjs.js +63 -57
- package/datatable/datatable.cjs.min.js +1 -1
- package/datatable/datatable.esm.js +63 -57
- package/datatable/datatable.esm.min.js +1 -1
- package/datatable/datatable.js +63 -57
- package/datatable/datatable.min.js +1 -1
- package/dataview/DataView.d.ts +65 -47
- package/dataviewlayoutoptions/DataViewLayoutOptions.d.ts +33 -13
- package/deferredcontent/DeferredContent.d.ts +30 -13
- package/dialog/Dialog.d.ts +67 -46
- package/dialogservice/DialogService.d.ts +13 -2
- package/divider/Divider.d.ts +35 -30
- package/dock/Dock.d.ts +49 -36
- package/dropdown/Dropdown.d.ts +90 -82
- package/dropdown/Dropdown.vue +1 -1
- package/dropdown/dropdown.cjs.js +1 -1
- package/dropdown/dropdown.cjs.min.js +1 -1
- package/dropdown/dropdown.esm.js +1 -1
- package/dropdown/dropdown.esm.min.js +1 -1
- package/dropdown/dropdown.js +1 -1
- package/dropdown/dropdown.min.js +1 -1
- package/dynamicdialog/DynamicDialog.d.ts +30 -10
- package/dynamicdialog/DynamicDialog.vue +2 -2
- package/dynamicdialog/dynamicdialog.cjs.js +3 -3
- package/dynamicdialog/dynamicdialog.cjs.min.js +1 -1
- package/dynamicdialog/dynamicdialog.esm.js +2 -2
- package/dynamicdialog/dynamicdialog.esm.min.js +1 -1
- package/dynamicdialog/dynamicdialog.js +3 -3
- package/dynamicdialog/dynamicdialog.min.js +1 -1
- package/dynamicdialogoptions/DynamicDialogOptions.d.ts +28 -8
- package/editor/Editor.d.ts +48 -17
- package/fieldset/Fieldset.d.ts +43 -16
- package/fileupload/FileUpload.d.ts +101 -47
- package/focustrap/FocusTrap.d.ts +42 -3
- package/fullcalendar/FullCalendar.d.ts +1 -1
- package/galleria/Galleria.d.ts +64 -40
- package/image/Image.d.ts +33 -14
- package/inlinemessage/InlineMessage.d.ts +31 -17
- package/inplace/Inplace.d.ts +41 -18
- package/inputmask/InputMask.d.ts +41 -17
- package/inputnumber/InputNumber.d.ts +60 -41
- package/inputswitch/InputSwitch.d.ts +35 -15
- package/inputswitch/InputSwitch.vue +1 -0
- package/inputswitch/inputswitch.cjs.js +1 -1
- package/inputswitch/inputswitch.cjs.min.js +1 -1
- package/inputswitch/inputswitch.esm.js +1 -1
- package/inputswitch/inputswitch.esm.min.js +1 -1
- package/inputswitch/inputswitch.js +1 -1
- package/inputswitch/inputswitch.min.js +1 -1
- package/inputtext/InputText.d.ts +32 -12
- package/knob/Knob.d.ts +47 -21
- package/listbox/Listbox.d.ts +81 -60
- package/megamenu/MegaMenu.d.ts +42 -27
- package/megamenu/MegaMenu.vue +17 -0
- package/megamenu/megamenu.cjs.js +1 -1
- package/megamenu/megamenu.cjs.min.js +1 -1
- package/megamenu/megamenu.esm.js +1 -1
- package/megamenu/megamenu.esm.min.js +1 -1
- package/megamenu/megamenu.js +1 -1
- package/megamenu/megamenu.min.js +1 -1
- package/menu/Menu.d.ts +51 -30
- package/menubar/Menubar.d.ts +36 -19
- package/menuitem/MenuItem.d.ts +22 -10
- package/message/Message.d.ts +40 -21
- package/multiselect/MultiSelect.d.ts +111 -90
- package/orderlist/OrderList.d.ts +51 -23
- package/organizationchart/OrganizationChart.d.ts +43 -26
- package/overlaypanel/OverlayPanel.d.ts +46 -26
- package/package.json +2 -2
- package/paginator/Paginator.d.ts +49 -24
- package/panel/Panel.d.ts +39 -14
- package/panelmenu/PanelMenu.d.ts +49 -21
- package/password/Password.d.ts +47 -28
- package/picklist/PickList.d.ts +74 -33
- package/progressbar/ProgressBar.d.ts +34 -17
- package/progressspinner/ProgressSpinner.d.ts +32 -13
- package/radiobutton/RadioButton.d.ts +32 -14
- package/rating/Rating.d.ts +51 -25
- package/resources/themes/arya-blue/theme.css +34 -11
- package/resources/themes/arya-green/theme.css +34 -11
- package/resources/themes/arya-orange/theme.css +34 -11
- package/resources/themes/arya-purple/theme.css +34 -11
- package/resources/themes/bootstrap4-dark-blue/theme.css +34 -11
- package/resources/themes/bootstrap4-dark-purple/theme.css +34 -11
- package/resources/themes/bootstrap4-light-blue/theme.css +34 -11
- package/resources/themes/bootstrap4-light-purple/theme.css +34 -11
- package/resources/themes/fluent-light/theme.css +34 -11
- package/resources/themes/lara-dark-blue/theme.css +34 -11
- package/resources/themes/lara-dark-indigo/theme.css +34 -11
- package/resources/themes/lara-dark-purple/theme.css +34 -11
- package/resources/themes/lara-dark-teal/theme.css +34 -11
- package/resources/themes/lara-light-blue/theme.css +34 -11
- package/resources/themes/lara-light-indigo/theme.css +34 -11
- package/resources/themes/lara-light-purple/theme.css +34 -11
- package/resources/themes/lara-light-teal/theme.css +34 -11
- package/resources/themes/luna-amber/theme.css +34 -11
- package/resources/themes/luna-blue/theme.css +34 -11
- package/resources/themes/luna-green/theme.css +34 -11
- package/resources/themes/luna-pink/theme.css +34 -11
- package/resources/themes/md-dark-deeppurple/theme.css +34 -11
- package/resources/themes/md-dark-indigo/theme.css +34 -11
- package/resources/themes/md-light-deeppurple/theme.css +34 -11
- package/resources/themes/md-light-indigo/theme.css +34 -11
- package/resources/themes/mdc-dark-deeppurple/theme.css +34 -11
- package/resources/themes/mdc-dark-indigo/theme.css +34 -11
- package/resources/themes/mdc-light-deeppurple/theme.css +34 -11
- package/resources/themes/mdc-light-indigo/theme.css +34 -11
- package/resources/themes/mira/theme.css +34 -11
- package/resources/themes/nano/theme.css +34 -11
- package/resources/themes/nova/theme.css +34 -11
- package/resources/themes/nova-accent/theme.css +34 -11
- package/resources/themes/nova-alt/theme.css +34 -11
- package/resources/themes/nova-vue/theme.css +34 -11
- package/resources/themes/rhea/theme.css +34 -11
- package/resources/themes/saga-blue/theme.css +34 -11
- package/resources/themes/saga-green/theme.css +34 -11
- package/resources/themes/saga-orange/theme.css +34 -11
- package/resources/themes/saga-purple/theme.css +34 -11
- package/resources/themes/soho-dark/theme.css +34 -11
- package/resources/themes/soho-light/theme.css +34 -11
- package/resources/themes/tailwind-light/theme.css +34 -11
- package/resources/themes/vela-blue/theme.css +34 -11
- package/resources/themes/vela-green/theme.css +34 -11
- package/resources/themes/vela-orange/theme.css +34 -11
- package/resources/themes/vela-purple/theme.css +34 -11
- package/resources/themes/viva-dark/theme.css +34 -11
- package/resources/themes/viva-light/theme.css +34 -11
- package/ripple/Ripple.d.ts +24 -1
- package/row/Row.d.ts +28 -10
- package/scrollpanel/ScrollPanel.d.ts +29 -11
- package/scrolltop/ScrollTop.d.ts +35 -18
- package/selectbutton/SelectButton.d.ts +47 -27
- package/sidebar/Sidebar.d.ts +46 -27
- package/skeleton/Skeleton.d.ts +36 -22
- package/slider/Slider.d.ts +46 -23
- package/speeddial/SpeedDial.d.ts +64 -51
- package/splitbutton/SplitButton.d.ts +73 -24
- package/splitbutton/SplitButton.vue +41 -1
- package/splitbutton/splitbutton.cjs.js +43 -3
- package/splitbutton/splitbutton.cjs.min.js +1 -1
- package/splitbutton/splitbutton.esm.js +43 -3
- package/splitbutton/splitbutton.esm.min.js +1 -1
- package/splitbutton/splitbutton.js +43 -3
- package/splitbutton/splitbutton.min.js +1 -1
- package/splitter/Splitter.d.ts +49 -30
- package/splitterpanel/SplitterPanel.d.ts +28 -10
- package/steps/Steps.d.ts +36 -15
- package/styleclass/StyleClass.d.ts +72 -1
- package/tabmenu/TabMenu.d.ts +41 -16
- package/tabmenu/TabMenu.vue +1 -1
- package/tabmenu/tabmenu.cjs.js +1 -0
- package/tabmenu/tabmenu.cjs.min.js +1 -1
- package/tabmenu/tabmenu.esm.js +1 -0
- package/tabmenu/tabmenu.esm.min.js +1 -1
- package/tabmenu/tabmenu.js +1 -0
- package/tabmenu/tabmenu.min.js +1 -1
- package/tabpanel/TabPanel.d.ts +29 -11
- package/tabview/TabView.d.ts +47 -19
- package/tag/Tag.d.ts +33 -15
- package/terminal/Terminal.d.ts +30 -14
- package/terminalservice/TerminalService.d.ts +24 -5
- package/textarea/Textarea.d.ts +33 -11
- package/tieredmenu/TieredMenu.d.ts +45 -31
- package/timeline/Timeline.d.ts +41 -32
- package/toast/Toast.d.ts +63 -35
- package/toast/Toast.vue +4 -2
- package/toast/ToastMessage.vue +4 -4
- package/toast/toast.cjs.js +8 -6
- package/toast/toast.cjs.min.js +1 -1
- package/toast/toast.esm.js +8 -6
- package/toast/toast.esm.min.js +1 -1
- package/toast/toast.js +8 -6
- package/toast/toast.min.js +1 -1
- package/toastservice/ToastService.d.ts +16 -3
- package/togglebutton/ToggleButton.d.ts +42 -22
- package/toolbar/Toolbar.d.ts +34 -14
- package/tooltip/Tooltip.d.ts +99 -1
- package/tree/Tree.d.ts +55 -36
- package/treeselect/TreeSelect.d.ts +63 -55
- package/treetable/TreeTable.d.ts +121 -107
- package/tristatecheckbox/TriStateCheckbox.d.ts +35 -12
- package/ts-helpers.d.ts +2 -2
- package/utils/utils.cjs.js +18 -15
- package/utils/utils.cjs.min.js +1 -1
- package/utils/utils.esm.js +18 -15
- package/utils/utils.esm.min.js +1 -1
- package/utils/utils.js +18 -15
- package/utils/utils.min.js +1 -1
- package/vetur-attributes.json +62 -2
- package/vetur-tags.json +17 -2
- package/virtualscroller/VirtualScroller.d.ts +99 -43
- package/virtualscroller/VirtualScroller.vue +248 -72
- package/virtualscroller/virtualscroller.cjs.js +234 -72
- package/virtualscroller/virtualscroller.cjs.min.js +1 -1
- package/virtualscroller/virtualscroller.esm.js +234 -72
- package/virtualscroller/virtualscroller.esm.min.js +1 -1
- package/virtualscroller/virtualscroller.js +235 -74
- package/virtualscroller/virtualscroller.min.js +1 -1
- package/web-types.json +1922 -1744
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
</template>
|
|
43
43
|
|
|
44
44
|
<script>
|
|
45
|
+
import { DomHandler } from 'primevue/utils';
|
|
46
|
+
|
|
45
47
|
export default {
|
|
46
48
|
name: 'VirtualScroller',
|
|
47
49
|
emits: ['update:numToleratedItems', 'scroll', 'scroll-index-change', 'lazy-load'],
|
|
@@ -74,6 +76,10 @@ export default {
|
|
|
74
76
|
type: Number,
|
|
75
77
|
default: 0
|
|
76
78
|
},
|
|
79
|
+
resizeDelay: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: 10
|
|
82
|
+
},
|
|
77
83
|
lazy: {
|
|
78
84
|
type: Boolean,
|
|
79
85
|
default: false
|
|
@@ -105,12 +111,29 @@ export default {
|
|
|
105
111
|
tabindex: {
|
|
106
112
|
type: Number,
|
|
107
113
|
default: 0
|
|
114
|
+
},
|
|
115
|
+
inline: {
|
|
116
|
+
type: Boolean,
|
|
117
|
+
default: false
|
|
118
|
+
},
|
|
119
|
+
step: {
|
|
120
|
+
type: Number,
|
|
121
|
+
default: 0
|
|
122
|
+
},
|
|
123
|
+
appendOnly: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
default: false
|
|
126
|
+
},
|
|
127
|
+
autoSize: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: false
|
|
108
130
|
}
|
|
109
131
|
},
|
|
110
132
|
data() {
|
|
111
133
|
return {
|
|
112
134
|
first: this.isBoth() ? { rows: 0, cols: 0 } : 0,
|
|
113
135
|
last: this.isBoth() ? { rows: 0, cols: 0 } : 0,
|
|
136
|
+
page: this.isBoth() ? { rows: 0, cols: 0 } : 0,
|
|
114
137
|
numItemsInViewport: this.isBoth() ? { rows: 0, cols: 0 } : 0,
|
|
115
138
|
lastScrollPos: this.isBoth() ? { top: 0, left: 0 } : 0,
|
|
116
139
|
d_numToleratedItems: this.numToleratedItems,
|
|
@@ -124,6 +147,15 @@ export default {
|
|
|
124
147
|
content: null,
|
|
125
148
|
lastScrollPos: null,
|
|
126
149
|
scrollTimeout: null,
|
|
150
|
+
resizeTimeout: null,
|
|
151
|
+
defaultWidth: 0,
|
|
152
|
+
defaultHeight: 0,
|
|
153
|
+
defaultContentWidth: 0,
|
|
154
|
+
defaultContentHeight: 0,
|
|
155
|
+
isRangeChanged: false,
|
|
156
|
+
lazyLoadState: {},
|
|
157
|
+
resizeListener: null,
|
|
158
|
+
initialized: false,
|
|
127
159
|
watch: {
|
|
128
160
|
numToleratedItems(newValue) {
|
|
129
161
|
this.d_numToleratedItems = newValue;
|
|
@@ -134,22 +166,59 @@ export default {
|
|
|
134
166
|
items(newValue, oldValue) {
|
|
135
167
|
if (!oldValue || oldValue.length !== (newValue || []).length) {
|
|
136
168
|
this.init();
|
|
169
|
+
this.calculateAutoSize();
|
|
137
170
|
}
|
|
138
171
|
},
|
|
172
|
+
itemSize() {
|
|
173
|
+
this.init();
|
|
174
|
+
this.calculateAutoSize();
|
|
175
|
+
},
|
|
139
176
|
orientation() {
|
|
140
177
|
this.lastScrollPos = this.isBoth() ? { top: 0, left: 0 } : 0;
|
|
178
|
+
},
|
|
179
|
+
scrollHeight() {
|
|
180
|
+
this.init();
|
|
181
|
+
this.calculateAutoSize();
|
|
182
|
+
},
|
|
183
|
+
scrollWidth() {
|
|
184
|
+
this.init();
|
|
185
|
+
this.calculateAutoSize();
|
|
141
186
|
}
|
|
142
187
|
},
|
|
143
188
|
mounted() {
|
|
144
|
-
this.
|
|
189
|
+
this.viewInit();
|
|
145
190
|
|
|
146
191
|
this.lastScrollPos = this.isBoth() ? { top: 0, left: 0 } : 0;
|
|
192
|
+
this.lazyLoadState = this.lazyLoadState || {};
|
|
193
|
+
},
|
|
194
|
+
updated() {
|
|
195
|
+
!this.initialized && this.viewInit();
|
|
196
|
+
},
|
|
197
|
+
unmounted() {
|
|
198
|
+
this.unbindResizeListener();
|
|
199
|
+
|
|
200
|
+
this.initialized = false;
|
|
147
201
|
},
|
|
148
202
|
methods: {
|
|
203
|
+
viewInit() {
|
|
204
|
+
if (DomHandler.isVisible(this.element)) {
|
|
205
|
+
this.setContentEl(this.content);
|
|
206
|
+
this.init();
|
|
207
|
+
this.bindResizeListener();
|
|
208
|
+
|
|
209
|
+
this.defaultWidth = DomHandler.getWidth(this.element);
|
|
210
|
+
this.defaultHeight = DomHandler.getHeight(this.element);
|
|
211
|
+
this.defaultContentWidth = DomHandler.getWidth(this.content);
|
|
212
|
+
this.defaultContentHeight = DomHandler.getHeight(this.content);
|
|
213
|
+
this.initialized = true;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
149
216
|
init() {
|
|
150
|
-
this.
|
|
151
|
-
|
|
152
|
-
|
|
217
|
+
if (!this.disabled) {
|
|
218
|
+
this.setSize();
|
|
219
|
+
this.calculateOptions();
|
|
220
|
+
this.setSpacerSize();
|
|
221
|
+
}
|
|
153
222
|
},
|
|
154
223
|
isVertical() {
|
|
155
224
|
return this.orientation === 'vertical';
|
|
@@ -161,31 +230,34 @@ export default {
|
|
|
161
230
|
return this.orientation === 'both';
|
|
162
231
|
},
|
|
163
232
|
scrollTo(options) {
|
|
164
|
-
this.
|
|
233
|
+
this.lastScrollPos = this.both ? { top: 0, left: 0 } : 0;
|
|
234
|
+
this.element?.scrollTo(options);
|
|
165
235
|
},
|
|
166
236
|
scrollToIndex(index, behavior = 'auto') {
|
|
167
237
|
const both = this.isBoth();
|
|
168
238
|
const horizontal = this.isHorizontal();
|
|
169
239
|
const first = this.first;
|
|
170
240
|
const { numToleratedItems } = this.calculateNumItems();
|
|
241
|
+
const contentPos = this.getContentPosition();
|
|
171
242
|
const itemSize = this.itemSize;
|
|
172
243
|
const calculateFirst = (_index = 0, _numT) => (_index <= _numT ? 0 : _index);
|
|
173
|
-
const calculateCoord = (_first, _size) => _first * _size;
|
|
244
|
+
const calculateCoord = (_first, _size, _cpos) => _first * _size + _cpos;
|
|
174
245
|
const scrollTo = (left = 0, top = 0) => this.scrollTo({ left, top, behavior });
|
|
246
|
+
let newFirst = both ? { rows: 0, cols: 0 } : 0;
|
|
247
|
+
let isRangeChanged = false;
|
|
175
248
|
|
|
176
249
|
if (both) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
scrollTo(calculateCoord(newFirst.cols, itemSize[1]), calculateCoord(newFirst.rows, itemSize[0]));
|
|
181
|
-
}
|
|
250
|
+
newFirst = { rows: calculateFirst(index[0], numToleratedItems[0]), cols: calculateFirst(index[1], numToleratedItems[1]) };
|
|
251
|
+
scrollTo(calculateCoord(newFirst.cols, itemSize[1], contentPos.left), calculateCoord(newFirst.rows, itemSize[0], contentPos.top));
|
|
252
|
+
isRangeChanged = newFirst.rows !== first.rows || newFirst.cols !== first.cols;
|
|
182
253
|
} else {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
horizontal ? scrollTo(calculateCoord(newFirst, itemSize), 0) : scrollTo(0, calculateCoord(newFirst, itemSize));
|
|
187
|
-
}
|
|
254
|
+
newFirst = calculateFirst(index, numToleratedItems);
|
|
255
|
+
horizontal ? scrollTo(calculateCoord(newFirst, itemSize, contentPos.left), 0) : scrollTo(0, calculateCoord(newFirst, itemSize, contentPos.top));
|
|
256
|
+
isRangeChanged = newFirst !== first;
|
|
188
257
|
}
|
|
258
|
+
|
|
259
|
+
this.isRangeChanged = isRangeChanged;
|
|
260
|
+
this.first = newFirst;
|
|
189
261
|
},
|
|
190
262
|
scrollInView(index, to, behavior = 'auto') {
|
|
191
263
|
if (to) {
|
|
@@ -238,8 +310,7 @@ export default {
|
|
|
238
310
|
if (this.element) {
|
|
239
311
|
const both = this.isBoth();
|
|
240
312
|
const horizontal = this.isHorizontal();
|
|
241
|
-
const scrollTop = this.element.scrollTop;
|
|
242
|
-
const scrollLeft = this.element.scrollLeft;
|
|
313
|
+
const { scrollTop, scrollLeft } = this.element.scrollTop;
|
|
243
314
|
|
|
244
315
|
if (both) {
|
|
245
316
|
firstInViewport = { rows: calculateFirstInViewport(scrollTop, this.itemSize[0]), cols: calculateFirstInViewport(scrollLeft, this.itemSize[1]) };
|
|
@@ -282,7 +353,7 @@ export default {
|
|
|
282
353
|
const both = this.isBoth();
|
|
283
354
|
const first = this.first;
|
|
284
355
|
const { numItemsInViewport, numToleratedItems } = this.calculateNumItems();
|
|
285
|
-
const calculateLast = (_first, _num, _numT, _isCols) => this.getLast(_first + _num + (_first < _numT ? 2 : 3) * _numT, _isCols);
|
|
356
|
+
const calculateLast = (_first, _num, _numT, _isCols = false) => this.getLast(_first + _num + (_first < _numT ? 2 : 3) * _numT, _isCols);
|
|
286
357
|
const last = both
|
|
287
358
|
? { rows: calculateLast(first.rows, numItemsInViewport.rows, numToleratedItems[0]), cols: calculateLast(first.cols, numItemsInViewport.cols, numToleratedItems[1], true) }
|
|
288
359
|
: calculateLast(first, numItemsInViewport, numToleratedItems);
|
|
@@ -297,23 +368,55 @@ export default {
|
|
|
297
368
|
}
|
|
298
369
|
|
|
299
370
|
if (this.lazy) {
|
|
300
|
-
|
|
371
|
+
Promise.resolve().then(() => {
|
|
372
|
+
this.lazyLoadState = {
|
|
373
|
+
first: this.step ? (both ? { rows: 0, cols: first.cols } : 0) : first,
|
|
374
|
+
last: Math.min(this.step ? this.step : last, this.items.length)
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
this.$emit('lazy-load', this.lazyLoadState);
|
|
378
|
+
});
|
|
301
379
|
}
|
|
302
380
|
},
|
|
303
|
-
|
|
304
|
-
if (this.
|
|
305
|
-
|
|
306
|
-
|
|
381
|
+
calculateAutoSize() {
|
|
382
|
+
if (this.autoSize && !this.d_loading) {
|
|
383
|
+
Promise.resolve().then(() => {
|
|
384
|
+
if (this.content) {
|
|
385
|
+
const both = this.isBoth();
|
|
386
|
+
const horizontal = this.isHorizontal();
|
|
387
|
+
const vertical = this.isVertical();
|
|
388
|
+
|
|
389
|
+
this.content.style.minHeight = this.content.style.minWidth = 'auto';
|
|
390
|
+
this.content.style.position = 'relative';
|
|
391
|
+
this.element.style.contain = 'none';
|
|
307
392
|
|
|
308
|
-
|
|
393
|
+
const [contentWidth, contentHeight] = [DomHandler.getWidth(this.content), DomHandler.getHeight(this.content)];
|
|
394
|
+
|
|
395
|
+
contentWidth !== this.defaultContentWidth && (this.element.style.width = '');
|
|
396
|
+
contentHeight !== this.defaultContentHeight && (this.element.style.height = '');
|
|
397
|
+
|
|
398
|
+
const [width, height] = [DomHandler.getWidth(this.element), DomHandler.getHeight(this.element)];
|
|
399
|
+
|
|
400
|
+
(both || horizontal) && (this.element.style.width = width < this.defaultWidth ? width + 'px' : this.scrollWidth || this.defaultWidth + 'px');
|
|
401
|
+
(both || vertical) && (this.element.style.height = height < this.defaultHeight ? height + 'px' : this.scrollHeight || this.defaultHeight + 'px');
|
|
402
|
+
|
|
403
|
+
this.content.style.minHeight = this.content.style.minWidth = '';
|
|
404
|
+
this.content.style.position = '';
|
|
405
|
+
this.element.style.contain = '';
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
getLast(last = 0, isCols) {
|
|
411
|
+
return this.items ? Math.min(isCols ? (this.columns || this.items[0]).length : this.items.length, last) : 0;
|
|
309
412
|
},
|
|
310
413
|
getContentPosition() {
|
|
311
414
|
if (this.content) {
|
|
312
415
|
const style = getComputedStyle(this.content);
|
|
313
|
-
const left =
|
|
314
|
-
const right =
|
|
315
|
-
const top =
|
|
316
|
-
const bottom =
|
|
416
|
+
const left = parseFloat(style.paddingLeft) + Math.max(parseFloat(style.left) || 0, 0);
|
|
417
|
+
const right = parseFloat(style.paddingRight) + Math.max(parseFloat(style.right) || 0, 0);
|
|
418
|
+
const top = parseFloat(style.paddingTop) + Math.max(parseFloat(style.top) || 0, 0);
|
|
419
|
+
const bottom = parseFloat(style.paddingBottom) + Math.max(parseFloat(style.bottom) || 0, 0);
|
|
317
420
|
|
|
318
421
|
return { left, right, top, bottom, x: left + right, y: top + bottom };
|
|
319
422
|
}
|
|
@@ -355,15 +458,12 @@ export default {
|
|
|
355
458
|
}
|
|
356
459
|
},
|
|
357
460
|
setContentPosition(pos) {
|
|
358
|
-
if (this.content) {
|
|
461
|
+
if (this.content && !this.appendOnly) {
|
|
359
462
|
const both = this.isBoth();
|
|
360
463
|
const horizontal = this.isHorizontal();
|
|
361
464
|
const first = pos ? pos.first : this.first;
|
|
362
465
|
const calculateTranslateVal = (_first, _size) => _first * _size;
|
|
363
|
-
|
|
364
|
-
const setTransform = (_x = 0, _y = 0) => {
|
|
365
|
-
this.contentStyle = { ...this.contentStyle, ...{ transform: `translate3d(${_x}px, ${_y}px, 0)` } };
|
|
366
|
-
};
|
|
466
|
+
const setTransform = (_x = 0, _y = 0) => (this.contentStyle = { ...this.contentStyle, ...{ transform: `translate3d(${_x}px, ${_y}px, 0)` } });
|
|
367
467
|
|
|
368
468
|
if (both) {
|
|
369
469
|
setTransform(calculateTranslateVal(first.cols, this.itemSize[1]), calculateTranslateVal(first.rows, this.itemSize[0]));
|
|
@@ -412,33 +512,39 @@ export default {
|
|
|
412
512
|
if (both) {
|
|
413
513
|
const isScrollDown = this.lastScrollPos.top <= scrollTop;
|
|
414
514
|
const isScrollRight = this.lastScrollPos.left <= scrollLeft;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
rows:
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
515
|
+
|
|
516
|
+
if (!this.appendOnly || (this.appendOnly && (isScrollDown || isScrollRight))) {
|
|
517
|
+
const currentIndex = { rows: calculateCurrentIndex(scrollTop, this.itemSize[0]), cols: calculateCurrentIndex(scrollLeft, this.itemSize[1]) };
|
|
518
|
+
const triggerIndex = {
|
|
519
|
+
rows: calculateTriggerIndex(currentIndex.rows, this.first.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0], isScrollDown),
|
|
520
|
+
cols: calculateTriggerIndex(currentIndex.cols, this.first.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], isScrollRight)
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
newFirst = {
|
|
524
|
+
rows: calculateFirst(currentIndex.rows, triggerIndex.rows, this.first.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0], isScrollDown),
|
|
525
|
+
cols: calculateFirst(currentIndex.cols, triggerIndex.cols, this.first.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], isScrollRight)
|
|
526
|
+
};
|
|
527
|
+
newLast = {
|
|
528
|
+
rows: calculateLast(currentIndex.rows, newFirst.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0]),
|
|
529
|
+
cols: calculateLast(currentIndex.cols, newFirst.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], true)
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
isRangeChanged = newFirst.rows !== this.first.rows || newLast.rows !== this.last.rows || newFirst.cols !== this.first.cols || newLast.cols !== this.last.cols || this.isRangeChanged;
|
|
533
|
+
newScrollPos = { top: scrollTop, left: scrollLeft };
|
|
534
|
+
}
|
|
432
535
|
} else {
|
|
433
536
|
const scrollPos = horizontal ? scrollLeft : scrollTop;
|
|
434
537
|
const isScrollDownOrRight = this.lastScrollPos <= scrollPos;
|
|
435
|
-
const currentIndex = calculateCurrentIndex(scrollPos, this.itemSize);
|
|
436
|
-
const triggerIndex = calculateTriggerIndex(currentIndex, this.first, this.last, this.numItemsInViewport, this.d_numToleratedItems, isScrollDownOrRight);
|
|
437
538
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
539
|
+
if (!this.appendOnly || (this.appendOnly && isScrollDownOrRight)) {
|
|
540
|
+
const currentIndex = calculateCurrentIndex(scrollPos, this.itemSize);
|
|
541
|
+
const triggerIndex = calculateTriggerIndex(currentIndex, this.first, this.last, this.numItemsInViewport, this.d_numToleratedItems, isScrollDownOrRight);
|
|
542
|
+
|
|
543
|
+
newFirst = calculateFirst(currentIndex, triggerIndex, this.first, this.last, this.numItemsInViewport, this.d_numToleratedItems, isScrollDownOrRight);
|
|
544
|
+
newLast = calculateLast(currentIndex, newFirst, this.last, this.numItemsInViewport, this.d_numToleratedItems);
|
|
545
|
+
isRangeChanged = newFirst !== this.first || newLast !== this.last || this.isRangeChanged;
|
|
546
|
+
newScrollPos = scrollPos;
|
|
547
|
+
}
|
|
442
548
|
}
|
|
443
549
|
|
|
444
550
|
return {
|
|
@@ -462,21 +568,29 @@ export default {
|
|
|
462
568
|
|
|
463
569
|
this.$emit('scroll-index-change', newState);
|
|
464
570
|
|
|
465
|
-
if (this.lazy) {
|
|
466
|
-
|
|
571
|
+
if (this.lazy && this.isPageChanged(first)) {
|
|
572
|
+
const lazyLoadState = {
|
|
573
|
+
first: this.step ? Math.min(this.getPageByFirst(first) * this.step, this.items.length - this.step) : first,
|
|
574
|
+
last: Math.min(this.step ? (this.getPageByFirst(first) + 1) * this.step : last, this.items.length)
|
|
575
|
+
};
|
|
576
|
+
const isLazyStateChanged = this.lazyLoadState.first !== lazyLoadState.first || this.lazyLoadState.last !== lazyLoadState.last;
|
|
577
|
+
|
|
578
|
+
isLazyStateChanged && this.$emit('lazy-load', lazyLoadState);
|
|
579
|
+
this.lazyLoadState = lazyLoadState;
|
|
467
580
|
}
|
|
468
581
|
}
|
|
469
582
|
},
|
|
470
583
|
onScroll(event) {
|
|
471
584
|
this.$emit('scroll', event);
|
|
472
585
|
|
|
473
|
-
if (this.delay) {
|
|
586
|
+
if (this.delay && this.isPageChanged()) {
|
|
474
587
|
if (this.scrollTimeout) {
|
|
475
588
|
clearTimeout(this.scrollTimeout);
|
|
476
589
|
}
|
|
477
590
|
|
|
478
591
|
if (!this.d_loading && this.showLoader) {
|
|
479
|
-
const { isRangeChanged
|
|
592
|
+
const { isRangeChanged } = this.onScrollPositionChange(event);
|
|
593
|
+
const changed = isRangeChanged || (this.step ? this.isPageChanged() : false);
|
|
480
594
|
|
|
481
595
|
changed && (this.d_loading = true);
|
|
482
596
|
}
|
|
@@ -484,14 +598,56 @@ export default {
|
|
|
484
598
|
this.scrollTimeout = setTimeout(() => {
|
|
485
599
|
this.onScrollChange(event);
|
|
486
600
|
|
|
487
|
-
if (this.d_loading && this.showLoader && !this.lazy) {
|
|
601
|
+
if (this.d_loading && this.showLoader && (!this.lazy || this.loading === undefined)) {
|
|
488
602
|
this.d_loading = false;
|
|
603
|
+
this.page = this.getPageByFirst();
|
|
489
604
|
}
|
|
490
605
|
}, this.delay);
|
|
491
606
|
} else {
|
|
492
607
|
this.onScrollChange(event);
|
|
493
608
|
}
|
|
494
609
|
},
|
|
610
|
+
onResize() {
|
|
611
|
+
if (this.resizeTimeout) {
|
|
612
|
+
clearTimeout(this.resizeTimeout);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
this.resizeTimeout = setTimeout(() => {
|
|
616
|
+
if (DomHandler.isVisible(this.element)) {
|
|
617
|
+
const both = this.isBoth();
|
|
618
|
+
const vertical = this.isVertical();
|
|
619
|
+
const horizontal = this.isHorizontal();
|
|
620
|
+
const [width, height] = [DomHandler.getWidth(this.element), DomHandler.getHeight(this.element)];
|
|
621
|
+
const [isDiffWidth, isDiffHeight] = [width !== this.defaultWidth, height !== this.defaultHeight];
|
|
622
|
+
const reinit = both ? isDiffWidth || isDiffHeight : horizontal ? isDiffWidth : vertical ? isDiffHeight : false;
|
|
623
|
+
|
|
624
|
+
if (reinit) {
|
|
625
|
+
this.d_numToleratedItems = this.numToleratedItems;
|
|
626
|
+
this.defaultWidth = width;
|
|
627
|
+
this.defaultHeight = height;
|
|
628
|
+
this.defaultContentWidth = DomHandler.getWidth(this.content);
|
|
629
|
+
this.defaultContentHeight = DomHandler.getHeight(this.content);
|
|
630
|
+
|
|
631
|
+
this.init();
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}, this.resizeDelay);
|
|
635
|
+
},
|
|
636
|
+
bindResizeListener() {
|
|
637
|
+
if (!this.resizeListener) {
|
|
638
|
+
this.resizeListener = this.onResize.bind(this);
|
|
639
|
+
|
|
640
|
+
window.addEventListener('resize', this.resizeListener);
|
|
641
|
+
window.addEventListener('orientationchange', this.resizeListener);
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
unbindResizeListener() {
|
|
645
|
+
if (this.resizeListener) {
|
|
646
|
+
window.removeEventListener('resize', this.resizeListener);
|
|
647
|
+
window.removeEventListener('orientationchange', this.resizeListener);
|
|
648
|
+
this.resizeListener = null;
|
|
649
|
+
}
|
|
650
|
+
},
|
|
495
651
|
getOptions(renderedIndex) {
|
|
496
652
|
const count = (this.items || []).length;
|
|
497
653
|
const index = this.isBoth() ? this.first.rows + renderedIndex : this.first + renderedIndex;
|
|
@@ -518,6 +674,15 @@ export default {
|
|
|
518
674
|
...extOptions
|
|
519
675
|
};
|
|
520
676
|
},
|
|
677
|
+
getPageByFirst(first) {
|
|
678
|
+
return Math.floor(((first ?? this.first) + this.d_numToleratedItems * 4) / (this.step || 1));
|
|
679
|
+
},
|
|
680
|
+
isPageChanged(first) {
|
|
681
|
+
return this.step ? this.page !== this.getPageByFirst(first ?? this.first) : true;
|
|
682
|
+
},
|
|
683
|
+
setContentEl(el) {
|
|
684
|
+
this.content = el || this.content || DomHandler.findSingle(this.element, '.p-virtualscroller-content');
|
|
685
|
+
},
|
|
521
686
|
elementRef(el) {
|
|
522
687
|
this.element = el;
|
|
523
688
|
},
|
|
@@ -530,8 +695,9 @@ export default {
|
|
|
530
695
|
return [
|
|
531
696
|
'p-virtualscroller',
|
|
532
697
|
{
|
|
533
|
-
'p-
|
|
534
|
-
'p-
|
|
698
|
+
'p-virtualscroller-inline': this.inline,
|
|
699
|
+
'p-virtualscroller-both p-both-scroll': this.isBoth(),
|
|
700
|
+
'p-virtualscroller-horizontal p-horizontal-scroll': this.isHorizontal()
|
|
535
701
|
},
|
|
536
702
|
this.class
|
|
537
703
|
];
|
|
@@ -553,13 +719,10 @@ export default {
|
|
|
553
719
|
];
|
|
554
720
|
},
|
|
555
721
|
loadedItems() {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
return items.slice(this.first.rows, this.last.rows).map((item) => (this.columns ? item : item.slice(this.first.cols, this.last.cols)));
|
|
561
|
-
} else if (this.isHorizontal() && this.columns) return items;
|
|
562
|
-
else return items.slice(this.first, this.last);
|
|
722
|
+
if (this.items && !this.d_loading) {
|
|
723
|
+
if (this.isBoth()) return this.items.slice(this.appendOnly ? 0 : this.first.rows, this.last.rows).map((item) => (this.columns ? item : item.slice(this.appendOnly ? 0 : this.first.cols, this.last.cols)));
|
|
724
|
+
else if (this.isHorizontal() && this.columns) return this.items;
|
|
725
|
+
else return this.items.slice(this.appendOnly ? 0 : this.first, this.last);
|
|
563
726
|
}
|
|
564
727
|
|
|
565
728
|
return [];
|
|
@@ -597,7 +760,7 @@ export default {
|
|
|
597
760
|
position: absolute;
|
|
598
761
|
top: 0;
|
|
599
762
|
left: 0;
|
|
600
|
-
contain: content;
|
|
763
|
+
/* contain: content; */
|
|
601
764
|
min-height: 100%;
|
|
602
765
|
min-width: 100%;
|
|
603
766
|
will-change: transform;
|
|
@@ -626,4 +789,17 @@ export default {
|
|
|
626
789
|
align-items: center;
|
|
627
790
|
justify-content: center;
|
|
628
791
|
}
|
|
792
|
+
|
|
793
|
+
.p-virtualscroller-loading-icon {
|
|
794
|
+
font-size: 2rem;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
.p-virtualscroller-horizontal > .p-virtualscroller-content {
|
|
798
|
+
display: flex;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/* Inline */
|
|
802
|
+
.p-virtualscroller-inline .p-virtualscroller-content {
|
|
803
|
+
position: static;
|
|
804
|
+
}
|
|
629
805
|
</style>
|