-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Question : Is it possible to call ScrollTo_Y on <ListView/> Component? #1389
Comments
@MossP - you can get the underlying |
Thanks @brentvatne I'll try that out, thank you :) 👍 |
can we scroll to using a rowID ? |
@jawadrehman - you could use the UIManager measureLayoutRelativeToParent function to determine the position and then scroll to that |
@brentvatne so what parameters would i send to the function ? Thanks |
The function signature is:
So you need to pass in a ref to the component, then an error and success callback - the success callback will give you an array of values:
So let's say that your row has some ref like "mySpecialRow" then..
|
@brentvatne thanks for that... |
Same problem here : the refs defined within the Besides, the row we wish to scroll to might have not been rendered yet depending on current scroll position and Does that mean we have to use a @MossP @jawadrehman have you found a solution ? |
Hi @VonD I hadn't been trying to scroll to a particular item as you guys had. I was just scrolling to a fixed point (0) so the code provided suffices for me. |
@VonD Needed to do the same thing, scroll to an arbitrary view rendered in renderRow.
My scroll method looked something like this: var cellHandle = React.findNodeHandle(this.cell);
UIManager.measureLayoutRelativeToParent(cellHandle, () => {}, (x, cellY, width, cellHeight) => {
var listHandle = React.findNodeHandle(this.state.listView());
UIManager.measureLayoutRelativeToParent(listHandle, () => {}, (x, y, width, listHeight) => {
var position = cellY - ((listHeight / 2) - (cellHeight / 2));
listView.getScrollResponder().scrollWithoutAnimationTo(Math.round(position), 0);
});
}); Took awhile to figure this out, part of me really misses |
Just found another way to solve this, steps below
var row = <View><Text>{movie.title}</Text></View>;
this.$rows[movie.id] = row;
var row1 = this.$rows['12345']; // 12345 is the id of the row
var handle = React.findNodeHandle(row1._owner); // must add ._owner here
var m = UIManager.measureLayoutRelativeToParent(
handle,
(err)=>console.log( 'err:', arguments ),
(x, y, w, h)=>{
console.log( 'success: ', x,y,w,h );
this.$scrollView.scrollTo(y, x);
}) |
i.e. is it possible to call a method that scrolls a to a given position - the top in my instance.
The text was updated successfully, but these errors were encountered: