-
Notifications
You must be signed in to change notification settings - Fork 10
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
What i should do to disable auto scrolling behaviour when new item is added at top of list? #18
Comments
You can enable / disable the autoscroll behavior with the prop Just pass |
I checked with given props but it's not worked for me. I want to disable autoscrolling when i add new data at top or bottom inshort at both side. Can you please suggest me some way how can i do that? |
hi @krupalikevadiya I think I do not understand your case here. From your description, it seems that you do not want the autoscroll function at all (because autoscrolling is mainly for when new data is added). Then, using a normal FlatList would have been the simplest choice. May I know what is something that you want to do with AutoScrollFlatList here that normal FlatList cannot do for you? I will need a little more detailed description / image / pseudo code to add my opinion here. |
Okay first of all thanks for quick reply. |
I am suggesting you use a state like When the searching is performed, set it to false in the callback (maybe in the onChange callback of your search input box). When user manually scrolls (you can use the onScroll prop), set it to true. Then, you pass it like Hope this helps. |
Yaa i use it like that but it is not worked and always scrolled automatically when i add data at top or bototm. |
@krupalikevadiya that sounds weird. Is it possible you provide me with a minimal repo with dummy data which can reproduce this issue so I can take a look on it? |
Let me attach my app.js file here so you can check it. |
@krupalikevadiya thanks for the code. Let me get back to you as soon as possible. |
Hey @RageBill any update on it ? |
I do not have access to my computer yet. Will get back to you as soon as possible. |
hi @krupalikevadiya, turns out I was wrong with the usage of To clarify: To resolve your issue, I have released v1.11.0 in which I have added the Hope it helps! |
Hey @RageBill Thanks for your concern. I tested this newly added props and this props also doesn't work for me as if i add autoScrollDisabled={true} list is not scrolled when i add data at top but it is scrolled when i add data at bottom and with autoScrollDisabled={false} list is not scrolled when i add data at bottom but animation like scrolling is appear and list is scrolled when i add data at top. |
hi @krupalikevadiya let me test again and get back to you later today. When I was trying it out, it was working for me (based on your code). I will attach a working code snippet for you later. Hope this helps! |
Hi @krupalikevadiya I have tested and now understand your problem. When I tested with this: <AutoScrollFlatList
{...otherProps}
inverted={true}
autoScrollDisabled={true}
/> It matches your description - the auto-scrolling behaviour is no longer there, and it does not scroll when adding data to the top. However, when adding data at the bottom - the list "shifted". It is not scrolling (as it does not trigger animations). This is an expected behaviour - you can test with it against the official How to solve this? In your addTop() {
let prev = this.state.list_data
const additionalNumbers = Array.from(Array(10).keys())
.map((n) => ({
id: this.generateUniqueKey(),
value: prev[0].value - n - 1,
}))
.reverse();
let final_data = additionalNumbers.concat(prev);
/**
* Adjust the scrollTop to make the view unchanged
*/
this.setState({ list_data: final_data }, () => {
if (this.ref.current) {
this.ref.current.getNativeScrollRef().scrollTo({y: this.ref.current.scrollTop + 100 * 10, animated: false})
}
})
} Please make sure you have done this for the ref: export default class App extends React.Component {
ref = React.createRef();
(...many other codes...)
<AutoScrollFlatList
ref={this.ref}
{...otherProps}
/>
(...many other codes...)
} Hope this helps! |
No description provided.
The text was updated successfully, but these errors were encountered: