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

Why is it judged that the automatic return to the top is not the latest position after the layout is updated? #50

Open
wqhui opened this issue Dec 19, 2024 · 0 comments

Comments

@wqhui
Copy link

wqhui commented Dec 19, 2024

Introduction to autoscrollToTopThreshold in https://reactnative.dev/docs/scrollview#maintainvisiblecontentposition

The optional autoscrollToTopThreshold can be used to make the content automatically scroll to the top after making the adjustment if the user was within the threshold

But I found in the code that the automatic return to the top is implemented after the layout calculation is completed. The ScrollY of the ScrollView will be reset here, but the latest ScrollY value is not used when judging whether to return to the top (the value of isWithinThreshold).

int currentScrollY = scrollViewUIHolder.getCurrentScrollY();
boolean isWithinThreshold = currentScrollY <= autoscrollToTopThreshold;
scrollView.setScrollY(currentScrollY + deltaY);
// If the offset WAS within the threshold of the start, animate to the start.
if (isWithinThreshold) {
scrollView.smoothScrollTo(scrollView.getScrollX(), 0);
}

Why is it judged that the automatic return to the top is not the latest position after the layout is updated?

I don’t know if anyone can answer my doubts 🙏 🙏 🙏

Because I found that when the last card changes from a small height to a large height, there is a probability that there will be a constant jitter back to the top.

@wqhui wqhui changed the title Why determine whether the scroll exceeds the threshold and automatically return to the top instead of using the latest position after layout update Why is it judged that the automatic return to the top is not the latest position after the layout is updated? Dec 19, 2024
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