You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, I just tested your repro (thanks for submitting btw!) and on a fresh 0.59 project the scroll to button works are expected.
My understanding is that your code wants to have the item to be in the center of the screen, but you are not considering the screen dimensions when you fire the scrollTo method.
So if you change your code to
handleScrollToCenter = () => {
if (this.containerRef && this.activeRef) {
const { height } = Dimensions.get('window'); // THIS LINE
const UIManager = NativeModules.UIManager;
UIManager.measure(
findNodeHandle(this.activeRef),
(activeX, activeY, activeW, activeH) => {
this.containerRef.scrollTo({
x: 0,
y: activeY - height / 2, // THIS LINE
animated: true
});
}
);
}
};
You should be able to have the desired effect (just tested locally).
If you try to scroll by hand - scroll view is respecting dimensions (I'm sorry, English is not my native language, so probably I can't explain it). You cannot scroll view like on screen, 20th row always . should be on bottom. But scrollTo scrolling to center (it's not "human" behaviour)
Environment
Description
Scroll is working well in sandbox https://codesandbox.io/s/1q1lq1407
But does not work in React Native. Seems like scroll does not check ScrollView dimensions
Reproducible Demo
Working example (probably, related to react-native-web?) https://codesandbox.io/s/1q1lq1407
Repository with reproducible example: https://github.com/indapublic/scrolltest
The text was updated successfully, but these errors were encountered: