primevue-mirror/components/virtualscroller/VirtualScroller.vue

630 lines
25 KiB
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
<template v-if="!disabled">
<div :ref="elementRef" :class="containerClass" :tabindex="tabindex" :style="style" @scroll="onScroll">
2022-09-14 11:26:01 +00:00
<slot
name="content"
:styleClass="contentClass"
:items="loadedItems"
:getItemOptions="getOptions"
:loading="d_loading"
:getLoaderOptions="getLoaderOptions"
:itemSize="itemSize"
:rows="loadedRows"
:columns="loadedColumns"
:contentRef="contentRef"
:spacerStyle="spacerStyle"
:contentStyle="contentStyle"
:vertical="isVertical()"
:horizontal="isHorizontal()"
:both="isBoth()"
>
2022-09-06 12:03:37 +00:00
<div :ref="contentRef" :class="contentClass" :style="contentStyle">
<template v-for="(item, index) of loadedItems" :key="index">
<slot name="item" :item="item" :options="getOptions(index)"></slot>
</template>
</div>
</slot>
2022-09-14 11:26:01 +00:00
<div v-if="showSpacer" class="p-virtualscroller-spacer" :style="spacerStyle"></div>
<div v-if="!loaderDisabled && showLoader && d_loading" :class="loaderClass">
2022-09-06 12:03:37 +00:00
<template v-if="$slots && $slots.loader">
<template v-for="(_, index) of loaderArr" :key="index">
<slot name="loader" :options="getLoaderOptions(index, isBoth() && { numCols: d_numItemsInViewport.cols })"></slot>
</template>
</template>
<i v-else class="p-virtualscroller-loading-icon pi pi-spinner pi-spin"></i>
</div>
</div>
</template>
<template v-else>
<slot></slot>
<slot name="content" :items="items" :rows="items" :columns="loadedColumns"></slot>
</template>
</template>
<script>
export default {
name: 'VirtualScroller',
emits: ['update:numToleratedItems', 'scroll', 'scroll-index-change', 'lazy-load'],
props: {
id: {
type: String,
default: null
},
style: null,
class: null,
items: {
type: Array,
default: null
},
itemSize: {
2022-09-14 11:26:01 +00:00
type: [Number, Array],
2022-09-06 12:03:37 +00:00
default: 0
},
scrollHeight: null,
scrollWidth: null,
orientation: {
type: String,
default: 'vertical'
},
numToleratedItems: {
type: Number,
default: null
},
delay: {
type: Number,
default: 0
},
lazy: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
loaderDisabled: {
type: Boolean,
default: false
},
columns: {
type: Array,
default: null
},
loading: {
type: Boolean,
default: false
},
showSpacer: {
type: Boolean,
default: true
},
showLoader: {
type: Boolean,
default: false
},
tabindex: {
type: Number,
default: 0
}
},
data() {
return {
first: this.isBoth() ? { rows: 0, cols: 0 } : 0,
last: this.isBoth() ? { rows: 0, cols: 0 } : 0,
numItemsInViewport: this.isBoth() ? { rows: 0, cols: 0 } : 0,
lastScrollPos: this.isBoth() ? { top: 0, left: 0 } : 0,
d_numToleratedItems: this.numToleratedItems,
d_loading: this.loading,
loaderArr: [],
spacerStyle: {},
contentStyle: {}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
},
element: null,
content: null,
lastScrollPos: null,
scrollTimeout: null,
watch: {
numToleratedItems(newValue) {
this.d_numToleratedItems = newValue;
},
loading(newValue) {
this.d_loading = newValue;
},
items(newValue, oldValue) {
if (!oldValue || oldValue.length !== (newValue || []).length) {
this.init();
}
},
orientation() {
this.lastScrollPos = this.isBoth() ? { top: 0, left: 0 } : 0;
}
},
2022-09-14 11:26:01 +00:00
mounted() {
this.init();
this.lastScrollPos = this.isBoth() ? { top: 0, left: 0 } : 0;
},
2022-09-06 12:03:37 +00:00
methods: {
init() {
this.setSize();
this.calculateOptions();
this.setSpacerSize();
},
isVertical() {
return this.orientation === 'vertical';
},
isHorizontal() {
return this.orientation === 'horizontal';
},
isBoth() {
return this.orientation === 'both';
},
scrollTo(options) {
this.element && this.element.scrollTo(options);
},
scrollToIndex(index, behavior = 'auto') {
const both = this.isBoth();
const horizontal = this.isHorizontal();
const first = this.first;
const { numToleratedItems } = this.calculateNumItems();
const itemSize = this.itemSize;
const calculateFirst = (_index = 0, _numT) => (_index <= _numT ? 0 : _index);
2022-09-14 11:26:01 +00:00
const calculateCoord = (_first, _size) => _first * _size;
2022-09-06 12:03:37 +00:00
const scrollTo = (left = 0, top = 0) => this.scrollTo({ left, top, behavior });
if (both) {
const newFirst = { rows: calculateFirst(index[0], numToleratedItems[0]), cols: calculateFirst(index[1], numToleratedItems[1]) };
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
if (newFirst.rows !== first.rows || newFirst.cols !== first.cols) {
2022-09-14 11:26:01 +00:00
scrollTo(calculateCoord(newFirst.cols, itemSize[1]), calculateCoord(newFirst.rows, itemSize[0]));
2022-09-06 12:03:37 +00:00
}
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
const newFirst = calculateFirst(index, numToleratedItems);
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
if (newFirst !== first) {
horizontal ? scrollTo(calculateCoord(newFirst, itemSize), 0) : scrollTo(0, calculateCoord(newFirst, itemSize));
}
}
},
scrollInView(index, to, behavior = 'auto') {
if (to) {
const both = this.isBoth();
const horizontal = this.isHorizontal();
const { first, viewport } = this.getRenderedRange();
const scrollTo = (left = 0, top = 0) => this.scrollTo({ left, top, behavior });
const isToStart = to === 'to-start';
const isToEnd = to === 'to-end';
if (isToStart) {
if (both) {
if (viewport.first.rows - first.rows > index[0]) {
scrollTo(viewport.first.cols * this.itemSize[1], (viewport.first.rows - 1) * this.itemSize[0]);
2022-09-14 11:26:01 +00:00
} else if (viewport.first.cols - first.cols > index[1]) {
2022-09-06 12:03:37 +00:00
scrollTo((viewport.first.cols - 1) * this.itemSize[1], viewport.first.rows * this.itemSize[0]);
}
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
if (viewport.first - first > index) {
const pos = (viewport.first - 1) * this.itemSize;
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
horizontal ? scrollTo(pos, 0) : scrollTo(0, pos);
}
}
2022-09-14 11:26:01 +00:00
} else if (isToEnd) {
2022-09-06 12:03:37 +00:00
if (both) {
if (viewport.last.rows - first.rows <= index[0] + 1) {
scrollTo(viewport.first.cols * this.itemSize[1], (viewport.first.rows + 1) * this.itemSize[0]);
2022-09-14 11:26:01 +00:00
} else if (viewport.last.cols - first.cols <= index[1] + 1) {
2022-09-06 12:03:37 +00:00
scrollTo((viewport.first.cols + 1) * this.itemSize[1], viewport.first.rows * this.itemSize[0]);
}
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
if (viewport.last - first <= index + 1) {
const pos = (viewport.first + 1) * this.itemSize;
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
horizontal ? scrollTo(pos, 0) : scrollTo(0, pos);
}
}
}
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
this.scrollToIndex(index, behavior);
}
},
getRenderedRange() {
const calculateFirstInViewport = (_pos, _size) => Math.floor(_pos / (_size || _pos));
let firstInViewport = this.first;
let lastInViewport = 0;
if (this.element) {
const both = this.isBoth();
const horizontal = this.isHorizontal();
const scrollTop = this.element.scrollTop;
const scrollLeft = this.element.scrollLeft;
if (both) {
firstInViewport = { rows: calculateFirstInViewport(scrollTop, this.itemSize[0]), cols: calculateFirstInViewport(scrollLeft, this.itemSize[1]) };
lastInViewport = { rows: firstInViewport.rows + this.numItemsInViewport.rows, cols: firstInViewport.cols + this.numItemsInViewport.cols };
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
const scrollPos = horizontal ? scrollLeft : scrollTop;
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
firstInViewport = calculateFirstInViewport(scrollPos, this.itemSize);
lastInViewport = firstInViewport + this.numItemsInViewport;
}
}
return {
first: this.first,
last: this.last,
viewport: {
first: firstInViewport,
last: lastInViewport
}
};
},
calculateNumItems() {
const both = this.isBoth();
const horizontal = this.isHorizontal();
const itemSize = this.itemSize;
const contentPos = this.getContentPosition();
const contentWidth = this.element ? this.element.offsetWidth - contentPos.left : 0;
const contentHeight = this.element ? this.element.offsetHeight - contentPos.top : 0;
const calculateNumItemsInViewport = (_contentSize, _itemSize) => Math.ceil(_contentSize / (_itemSize || _contentSize));
const calculateNumToleratedItems = (_numItems) => Math.ceil(_numItems / 2);
2022-09-14 11:26:01 +00:00
const numItemsInViewport = both
? { rows: calculateNumItemsInViewport(contentHeight, itemSize[0]), cols: calculateNumItemsInViewport(contentWidth, itemSize[1]) }
: calculateNumItemsInViewport(horizontal ? contentWidth : contentHeight, itemSize);
2022-09-06 12:03:37 +00:00
2022-09-14 11:26:01 +00:00
const numToleratedItems = this.d_numToleratedItems || (both ? [calculateNumToleratedItems(numItemsInViewport.rows), calculateNumToleratedItems(numItemsInViewport.cols)] : calculateNumToleratedItems(numItemsInViewport));
2022-09-06 12:03:37 +00:00
return { numItemsInViewport, numToleratedItems };
},
calculateOptions() {
const both = this.isBoth();
const first = this.first;
const { numItemsInViewport, numToleratedItems } = this.calculateNumItems();
2022-09-14 11:26:01 +00:00
const calculateLast = (_first, _num, _numT, _isCols) => this.getLast(_first + _num + (_first < _numT ? 2 : 3) * _numT, _isCols);
const last = both
? { rows: calculateLast(first.rows, numItemsInViewport.rows, numToleratedItems[0]), cols: calculateLast(first.cols, numItemsInViewport.cols, numToleratedItems[1], true) }
: calculateLast(first, numItemsInViewport, numToleratedItems);
2022-09-06 12:03:37 +00:00
this.last = last;
this.numItemsInViewport = numItemsInViewport;
this.d_numToleratedItems = numToleratedItems;
this.$emit('update:numToleratedItems', this.d_numToleratedItems);
if (this.showLoader) {
2022-09-14 11:26:01 +00:00
this.loaderArr = both ? Array.from({ length: numItemsInViewport.rows }).map(() => Array.from({ length: numItemsInViewport.cols })) : Array.from({ length: numItemsInViewport });
2022-09-06 12:03:37 +00:00
}
if (this.lazy) {
this.$emit('lazy-load', { first, last });
}
},
getLast(last = 0, isCols) {
if (this.items) {
2022-09-14 11:26:01 +00:00
return Math.min(isCols ? (this.columns || this.items[0]).length : this.items.length, last);
2022-09-06 12:03:37 +00:00
}
return 0;
},
getContentPosition() {
if (this.content) {
const style = getComputedStyle(this.content);
const left = parseInt(style.paddingLeft, 10) + Math.max(parseInt(style.left, 10), 0);
const right = parseInt(style.paddingRight, 10) + Math.max(parseInt(style.right, 10), 0);
const top = parseInt(style.paddingTop, 10) + Math.max(parseInt(style.top, 10), 0);
const bottom = parseInt(style.paddingBottom, 10) + Math.max(parseInt(style.bottom, 10), 0);
return { left, right, top, bottom, x: left + right, y: top + bottom };
}
return { left: 0, right: 0, top: 0, bottom: 0, x: 0, y: 0 };
},
setSize() {
if (this.element) {
const both = this.isBoth();
const horizontal = this.isHorizontal();
const parentElement = this.element.parentElement;
2022-09-14 11:26:01 +00:00
const width = this.scrollWidth || `${this.element.offsetWidth || parentElement.offsetWidth}px`;
const height = this.scrollHeight || `${this.element.offsetHeight || parentElement.offsetHeight}px`;
const setProp = (_name, _value) => (this.element.style[_name] = _value);
2022-09-06 12:03:37 +00:00
if (both || horizontal) {
setProp('height', height);
setProp('width', width);
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
setProp('height', height);
}
}
},
setSpacerSize() {
const items = this.items;
if (items) {
const both = this.isBoth();
const horizontal = this.isHorizontal();
const contentPos = this.getContentPosition();
2022-09-14 11:26:01 +00:00
const setProp = (_name, _value, _size, _cpos = 0) => (this.spacerStyle = { ...this.spacerStyle, ...{ [`${_name}`]: (_value || []).length * _size + _cpos + 'px' } });
2022-09-06 12:03:37 +00:00
if (both) {
setProp('height', items, this.itemSize[0], contentPos.y);
2022-09-14 11:26:01 +00:00
setProp('width', this.columns || items[1], this.itemSize[1], contentPos.x);
} else {
horizontal ? setProp('width', this.columns || items, this.itemSize, contentPos.x) : setProp('height', items, this.itemSize, contentPos.y);
2022-09-06 12:03:37 +00:00
}
}
},
setContentPosition(pos) {
if (this.content) {
const both = this.isBoth();
const horizontal = this.isHorizontal();
const first = pos ? pos.first : this.first;
2022-09-14 11:26:01 +00:00
const calculateTranslateVal = (_first, _size) => _first * _size;
2022-09-06 12:03:37 +00:00
const setTransform = (_x = 0, _y = 0) => {
this.contentStyle = { ...this.contentStyle, ...{ transform: `translate3d(${_x}px, ${_y}px, 0)` } };
};
if (both) {
setTransform(calculateTranslateVal(first.cols, this.itemSize[1]), calculateTranslateVal(first.rows, this.itemSize[0]));
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
const translateVal = calculateTranslateVal(first, this.itemSize);
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
horizontal ? setTransform(translateVal, 0) : setTransform(0, translateVal);
}
}
},
onScrollPositionChange(event) {
const target = event.target;
const both = this.isBoth();
const horizontal = this.isHorizontal();
const contentPos = this.getContentPosition();
2022-09-14 11:26:01 +00:00
const calculateScrollPos = (_pos, _cpos) => (_pos ? (_pos > _cpos ? _pos - _cpos : _pos) : 0);
2022-09-06 12:03:37 +00:00
const calculateCurrentIndex = (_pos, _size) => Math.floor(_pos / (_size || _pos));
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
const calculateTriggerIndex = (_currentIndex, _first, _last, _num, _numT, _isScrollDownOrRight) => {
2022-09-14 11:26:01 +00:00
return _currentIndex <= _numT ? _numT : _isScrollDownOrRight ? _last - _num - _numT : _first + _numT - 1;
2022-09-06 12:03:37 +00:00
};
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
const calculateFirst = (_currentIndex, _triggerIndex, _first, _last, _num, _numT, _isScrollDownOrRight) => {
2022-09-14 11:26:01 +00:00
if (_currentIndex <= _numT) return 0;
else return Math.max(0, _isScrollDownOrRight ? (_currentIndex < _triggerIndex ? _first : _currentIndex - _numT) : _currentIndex > _triggerIndex ? _first : _currentIndex - 2 * _numT);
2022-09-06 12:03:37 +00:00
};
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
const calculateLast = (_currentIndex, _first, _last, _num, _numT, _isCols) => {
2022-09-14 11:26:01 +00:00
let lastValue = _first + _num + 2 * _numT;
2022-09-06 12:03:37 +00:00
if (_currentIndex >= _numT) {
2022-09-14 11:26:01 +00:00
lastValue += _numT + 1;
2022-09-06 12:03:37 +00:00
}
return this.getLast(lastValue, _isCols);
};
const scrollTop = calculateScrollPos(target.scrollTop, contentPos.top);
const scrollLeft = calculateScrollPos(target.scrollLeft, contentPos.left);
let newFirst = both ? { rows: 0, cols: 0 } : 0;
let newLast = this.last;
let isRangeChanged = false;
let newScrollPos = this.lastScrollPos;
if (both) {
const isScrollDown = this.lastScrollPos.top <= scrollTop;
const isScrollRight = this.lastScrollPos.left <= scrollLeft;
const currentIndex = { rows: calculateCurrentIndex(scrollTop, this.itemSize[0]), cols: calculateCurrentIndex(scrollLeft, this.itemSize[1]) };
const triggerIndex = {
rows: calculateTriggerIndex(currentIndex.rows, this.first.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0], isScrollDown),
cols: calculateTriggerIndex(currentIndex.cols, this.first.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], isScrollRight)
};
newFirst = {
rows: calculateFirst(currentIndex.rows, triggerIndex.rows, this.first.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0], isScrollDown),
cols: calculateFirst(currentIndex.cols, triggerIndex.cols, this.first.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], isScrollRight)
};
newLast = {
rows: calculateLast(currentIndex.rows, newFirst.rows, this.last.rows, this.numItemsInViewport.rows, this.d_numToleratedItems[0]),
cols: calculateLast(currentIndex.cols, newFirst.cols, this.last.cols, this.numItemsInViewport.cols, this.d_numToleratedItems[1], true)
};
2022-09-14 11:26:01 +00:00
isRangeChanged = newFirst.rows !== this.first.rows || newLast.rows !== this.last.rows || newFirst.cols !== this.first.cols || newLast.cols !== this.last.cols;
2022-09-06 12:03:37 +00:00
newScrollPos = { top: scrollTop, left: scrollLeft };
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
const scrollPos = horizontal ? scrollLeft : scrollTop;
const isScrollDownOrRight = this.lastScrollPos <= scrollPos;
const currentIndex = calculateCurrentIndex(scrollPos, this.itemSize);
const triggerIndex = calculateTriggerIndex(currentIndex, this.first, this.last, this.numItemsInViewport, this.d_numToleratedItems, isScrollDownOrRight);
newFirst = calculateFirst(currentIndex, triggerIndex, this.first, this.last, this.numItemsInViewport, this.d_numToleratedItems, isScrollDownOrRight);
newLast = calculateLast(currentIndex, newFirst, this.last, this.numItemsInViewport, this.d_numToleratedItems);
isRangeChanged = newFirst !== this.first || newLast !== this.last;
newScrollPos = scrollPos;
}
return {
first: newFirst,
last: newLast,
isRangeChanged,
scrollPos: newScrollPos
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
},
onScrollChange(event) {
const { first, last, isRangeChanged, scrollPos } = this.onScrollPositionChange(event);
if (isRangeChanged) {
const newState = { first, last };
this.setContentPosition(newState);
this.first = first;
this.last = last;
this.lastScrollPos = scrollPos;
this.$emit('scroll-index-change', newState);
if (this.lazy) {
this.$emit('lazy-load', newState);
}
}
},
onScroll(event) {
this.$emit('scroll', event);
if (this.delay) {
if (this.scrollTimeout) {
clearTimeout(this.scrollTimeout);
}
if (!this.d_loading && this.showLoader) {
const { isRangeChanged: changed } = this.onScrollPositionChange(event);
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
changed && (this.d_loading = true);
}
this.scrollTimeout = setTimeout(() => {
this.onScrollChange(event);
if (this.d_loading && this.showLoader && !this.lazy) {
this.d_loading = false;
}
}, this.delay);
2022-09-14 11:26:01 +00:00
} else {
2022-09-06 12:03:37 +00:00
this.onScrollChange(event);
}
},
getOptions(renderedIndex) {
const count = (this.items || []).length;
const index = this.isBoth() ? this.first.rows + renderedIndex : this.first + renderedIndex;
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
return {
index,
count,
first: index === 0,
2022-09-14 11:26:01 +00:00
last: index === count - 1,
2022-09-06 12:03:37 +00:00
even: index % 2 === 0,
odd: index % 2 !== 0
};
},
getLoaderOptions(index, extOptions) {
let count = this.loaderArr.length;
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
return {
index,
count,
first: index === 0,
2022-09-14 11:26:01 +00:00
last: index === count - 1,
2022-09-06 12:03:37 +00:00
even: index % 2 === 0,
odd: index % 2 !== 0,
...extOptions
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
},
elementRef(el) {
this.element = el;
},
contentRef(el) {
this.content = el;
}
},
computed: {
containerClass() {
2022-09-14 11:26:01 +00:00
return [
'p-virtualscroller',
{
'p-both-scroll': this.isBoth(),
'p-horizontal-scroll': this.isHorizontal()
},
this.class
];
2022-09-06 12:03:37 +00:00
},
contentClass() {
2022-09-14 11:26:01 +00:00
return [
'p-virtualscroller-content',
{
'p-virtualscroller-loading': this.d_loading
}
];
2022-09-06 12:03:37 +00:00
},
loaderClass() {
2022-09-14 11:26:01 +00:00
return [
'p-virtualscroller-loader',
{
'p-component-overlay': !this.$slots.loader
}
];
2022-09-06 12:03:37 +00:00
},
loadedItems() {
const items = this.items;
2022-09-14 11:26:01 +00:00
2022-09-06 12:03:37 +00:00
if (items && !this.d_loading) {
if (this.isBoth()) {
2022-09-14 11:26:01 +00:00
return items.slice(this.first.rows, this.last.rows).map((item) => (this.columns ? item : item.slice(this.first.cols, this.last.cols)));
} else if (this.isHorizontal() && this.columns) return items;
else return items.slice(this.first, this.last);
2022-09-06 12:03:37 +00:00
}
return [];
},
loadedRows() {
return this.d_loading ? (this.loaderDisabled ? this.loaderArr : []) : this.loadedItems;
},
loadedColumns() {
if (this.columns) {
const both = this.isBoth();
const horizontal = this.isHorizontal();
if (both || horizontal) {
2022-09-14 11:26:01 +00:00
return this.d_loading && this.loaderDisabled ? (both ? this.loaderArr[0] : this.loaderArr) : this.columns.slice(both ? this.first.cols : this.first, both ? this.last.cols : this.last);
2022-09-06 12:03:37 +00:00
}
}
return this.columns;
}
}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
</script>
<style>
.p-virtualscroller {
position: relative;
overflow: auto;
contain: strict;
transform: translateZ(0);
will-change: scroll-position;
outline: 0 none;
}
.p-virtualscroller-content {
position: absolute;
top: 0;
left: 0;
contain: content;
min-height: 100%;
min-width: 100%;
will-change: transform;
}
.p-virtualscroller-spacer {
position: absolute;
top: 0;
left: 0;
height: 1px;
width: 1px;
transform-origin: 0 0;
pointer-events: none;
}
.p-virtualscroller .p-virtualscroller-loader {
position: sticky;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.p-virtualscroller-loader.p-component-overlay {
display: flex;
align-items: center;
justify-content: center;
}
</style>