Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excess scrolling when snapping to offset (handleSnap) #4

Open
smagr173 opened this issue Oct 8, 2021 · 0 comments
Open

Excess scrolling when snapping to offset (handleSnap) #4

smagr173 opened this issue Oct 8, 2021 · 0 comments

Comments

@smagr173
Copy link

smagr173 commented Oct 8, 2021

Within the handleSnap function there is scrollToOffset call
The amount to add or subtract from the current offset is a fixed number. This can result in a disproportionate amount of automatic scrolling during the snap. If the header bar has already been partially hidden then there will always be excess. Hence, the amount already hidden should be considered. Here is my solution
const halfHeader = headerHeight / 2;
const difference = halfHeader + translateYNumber.current;
getCloser(translateYNumber.current, -headerHeight / 2, 0) ===
-headerHeight / 2
? offsetY + difference
: offsetY-(halfHeader-difference)
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant