Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed Nov 24, 2023
1 parent ae02a1d commit bb4c87e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/core/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ export const createVirtualStore = (
const getScrollOffsetMax = () =>
getScrollSize() - viewportSize + paddingStart + paddingEnd;

const clampScrollOffset = (value: number): number => {
// Scroll offset may exceed min or max especially in Safari's elastic scrolling.
return clamp(value, 0, getScrollOffsetMax());
};
const applyJump = (j: ScrollJump) => {
// In iOS WebKit browsers, updating scroll position will stop scrolling so it have to be deferred during scrolling.
if (isIOSWebKit() && _scrollDirection !== SCROLL_IDLE) {
Expand Down Expand Up @@ -336,7 +332,9 @@ export const createVirtualStore = (
// Update synchronously if scrolled a lot
shouldSync = abs(delta) > viewportSize;

scrollOffset = clampScrollOffset(payload);
// Scroll offset may exceed min or max especially in Safari's elastic scrolling.
scrollOffset = clamp(payload, 0, getScrollOffsetMax());

mutated = UPDATE_SCROLL_STATE + UPDATE_SCROLL_WITH_EVENT;
break;
}
Expand Down

0 comments on commit bb4c87e

Please sign in to comment.