Trial - boosting prospect grid loading performance
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
export function attachScrollLoader(gridId, component) {
|
||||
const grid = document.getElementById(gridId);
|
||||
if (!grid) return;
|
||||
|
||||
const checkScroll = () => {
|
||||
const distanceFromBottom = grid.scrollHeight - (grid.scrollTop + grid.clientHeight);
|
||||
if (distanceFromBottom < 250) {
|
||||
component.invokeMethodAsync('OnScrollNearBottom');
|
||||
}
|
||||
};
|
||||
|
||||
grid.addEventListener('scroll', checkScroll, { passive: true });
|
||||
grid.__prospectScrollCheck = checkScroll;
|
||||
checkScroll();
|
||||
}
|
||||
|
||||
export function disposeScrollLoader(gridId) {
|
||||
const grid = document.getElementById(gridId);
|
||||
if (!grid || !grid.__prospectScrollCheck) return;
|
||||
|
||||
grid.removeEventListener('scroll', grid.__prospectScrollCheck);
|
||||
delete grid.__prospectScrollCheck;
|
||||
}
|
||||
Reference in New Issue
Block a user