On Coming Back from Details to List Page the scroll position goes back on top - List Data Loaded by Async task


#1

I have noticed that the issue of maintaining the Scroll position after coming back from the details page is fixed & it’s working fine.

But say I am loading the list data in a async process (most of the time, it will be) then the above functionality is broken & the list is going back on top.

For demonstrating

With the same example if I just return the result without any Async task , it works perfectly.
Now how to do that with the Async Case ?

Regards,
Sat


Back without losing scroll position
Save list view state
#2

Interesting point. I set up a sample that shows scroll position is retained when using synchronous code.

@andytjoslin or @adam You have suggestions on how to maintain scroll position when the list scope is reloaded?


#3

I hope someone or Ionic develop team will answer how to fix this async task soon. It’s really annoying!
Thank you!


#4

FYI : Have opened GitHub Issue # 719 on this topic : https://github.com/driftyco/ionic/issues/719


Scroll postion memory
#5

is that resolved yet in beta1? i couldnt tell its status from issue #719.


#6

The way, I am solving this issue is putting a check in the service to find if the Array is already populated (this will be the case if we are coming back to this page by pressing ‘Back’) & returning the already filled Array. This way there is no delay & the list can able to remember the scroll position.


#7

Thanks Sat for your reply here.
Just to get this right, are you caching the array so that when you nagivate away and then navigate back you populate the list from the cached array instead of calling the service again?


#8

exactly @michelhabib doing that only.


#9

It is very important to add this in the documentation!


#10

If you are using the latest Beta 14, this might not really necessary. With the new cached views, you will come back to the page without actually re-initializing the controller. So, the old data will be there and scrolled to the previous position.


Retain scroll on Ionic 3
#11

Nice, I will try it!


#12

Forewarned : Beta 14 is VERY different from Beta 13. You’re going to have to do a bit ( or a lot) of refactoring.


#13

any ideas about to implement this on Ionic 3?