Skip to content

Commit

Permalink
Update VirtualScroller.js
Browse files Browse the repository at this point in the history
Return first and last inside onScrollChange with both layout and lazy
  • Loading branch information
josmangarsal authored Jun 10, 2024
1 parent e978ce1 commit 4812c28
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/lib/virtualscroller/VirtualScroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export const VirtualScroller = React.memo(

if (props.lazy) {
Promise.resolve().then(() => {
lazyLoadState.current = {
lazyLoadState.current = both ? {first, last} : {
first: props.step ? (both ? { rows: 0, cols: firstState.cols } : 0) : firstState,
last: Math.min(props.step ? props.step : last, (props.items || []).length)
};
Expand Down Expand Up @@ -414,7 +414,7 @@ export const VirtualScroller = React.memo(
props.onScrollIndexChange && props.onScrollIndexChange(newState);

if (props.lazy && isPageChanged(first)) {
const newLazyLoadState = {
const newLazyLoadState = both ? {first, last} : {
first: props.step ? Math.min(getPageByFirst(first) * props.step, (props.items || []).length - props.step) : first,
last: Math.min(props.step ? (getPageByFirst(first) + 1) * props.step : last, (props.items || []).length)
};
Expand Down

0 comments on commit 4812c28

Please sign in to comment.