Skip to content

Commit

Permalink
Merge pull request #230 from inokawa/padding-scroll-max
Browse files Browse the repository at this point in the history
Include start padding in calculation of maximum scroll offset
  • Loading branch information
inokawa authored Oct 27, 2023
2 parents c3683c7 + 8370110 commit c3a4ab7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/core/scroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ export const createScroller = (
index = clamp(index, 0, store._getItemsLength() - 1);

if (align === "nearest") {
// TODO consider padding
const itemOffset = store._getItemOffset(index);
const scrollOffset = store._getScrollOffset();

Expand Down
3 changes: 2 additions & 1 deletion src/core/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export const createVirtualStore = (
const subscribers = new Set<[number, Subscriber]>();
const getScrollSize = (): number =>
computeTotalSize(cache as Writeable<Cache>);
const getScrollOffsetMax = () => getScrollSize() - viewportSize + paddingEnd;
const getScrollOffsetMax = () =>
getScrollSize() - viewportSize + paddingStart + paddingEnd;

const clampScrollOffset = (value: number): number => {
// Scroll offset may exceed min or max especially in Safari's elastic scrolling.
Expand Down

0 comments on commit c3a4ab7

Please sign in to comment.