0

I have a Sencha Touch infinite list (with scroll to top on refresh set to false) of chat messages – the most recent ones are at the bottom. When I load the store, the list always refreshes the view to the first record i.e. the topmost record i.e. the oldest chat message. I can scroll the list to bottom on refresh, but that scrolls the list after the view refreshes, meaning that the list scrolls from all the way to the top to all the way to the bottom. The behavior I want is that when the store loads, list should scroll to the bottom from the current view – so if there is only 1 message that was added due tot he loading of the store, I want the list to scroll by just the height of that one record.

The behavior is great when I do list.getStore().add(); followed by list scroll to bottom, but this is not the case when I load the store. What is the best way to get the same effect when the store loads – essentially, I don't want the view to reset to the top of the list but just scroll to the bottom from wherever the view is currently.

Please help! Thanks!

John Doe
  • 1,005
  • 2
  • 8
  • 23

2 Answers2

1

You would want to use list.scrollToRecord(store.getAt(store.getCount()-1))

Alexander
  • 19,906
  • 19
  • 75
  • 162
  • At what point do I call this? I tried doing this on refresh, but that scrolled down the list after the list was reset scrolled all the way to the top. I want it so that the list never resets the view but simply scrolls down to the bottom from the view it is in currently. – John Doe Oct 16 '14 at 15:27
  • You could only try using `store.load({addRecords:true})`. The store is cleared first, the list containing zero items, and then refilled, if you don't use addRecords. – Alexander Oct 16 '14 at 16:53
  • Hi @Alexander I tried that but doesn't seem to work. It always resets to the top then scrolls down to the bottom. Any other ideas? – John Doe Oct 18 '14 at 05:08
0

try scrollToTopOnRefresh: false at config

Alex P.
  • 1
  • 1