Scroll position on back

Was the nightly meant to fix this problem when toggling the left/right side menus?

Calling $scope.sideMenuController.toggleLeft(); causes the content pain to scroll to the top when toggling closed.

That’s a bug, @ethan ! Could you open an issue?

You guys are awesome for finding all these :slight_smile:

This works great for me guys. Thanks.

Sure @andytjoslin, issue opened - https://github.com/driftyco/ionic/issues/557

I just wanted to point out, that the same thing sometimes happens when i close a modal.

How about the list within the tabs? when I try to switch between the tab, the list always scroll to the top. Is possible to persist the position of list in tab?

1 Like

I’m having this problem - the view scrolls to the top when going back to it - despite it apparently being fixed according to this thread.

I’m running the latest (1.0.0-beta9). I’m new with Ionic, and would love to figure this one out if anyone has any ideas.

is this broken? even though I am going back in history, the view is not remembering the scroll position

Just in case this is still an issue for anyone, I’ve modified @gregorypratt’s directive and it works perfectly for me:

Directive (apply to <ion-content> tag as attribute):

angular.module('App.directives')

.directive('keepScroll', [
  
  '$state'
  '$timeout'
  'ScrollPositions'
  '$ionicScrollDelegate'
  
  ($state, $timeout, ScrollPositions, $ionicScrollDelegate) ->
    restrict: 'A'
    link: (scope, element, attrs) ->
      scope.$on '$stateChangeStart', ->
        ScrollPositions[$state.current.name] = $ionicScrollDelegate.getScrollPosition()
      
      $timeout ->
        offset = ScrollPositions[$state.current.name]
        $ionicScrollDelegate.scrollTo offset.left, offset.top if offset?
  
])

Service (trivial, could easily be modified to use LocalStorage for cross-session persistence):

angular.module('App.services')

.factory('ScrollPositions', [
  
  -> {}
  
])

Sorry if CoffeeScript isn’t your thing, but you should be able to pick up the logic if you’re a vanilla JS kinda guy. I hope this helps someone!

1 Like

Is there any version solved this by default ? I am using v1.0.0-rc.4-nightly-1257, still have this problem. Back to the list page will get the top of the list.

I’m having the same problem, when I go back to my list it doesn’t remember the scroll position (this is issue not working on Android only)

Since the release version I have the problem, the scrollposition is not restored on back - but only in the first displayed tab in the first view. In all the other tabs and views everything is working fine on history back or when changing the tab, but the first displayed tab view does not restore the scroll position and I have no idea why.

It already worked with the RC versions. Has there something changed in the handling and restoring of scroll positions with the release version?

Hello!
I tested with the last version and it worked well.
But it’s not working when I use overflow-scroll=“true” on the ion-content.

It not works when I use overflow-scroll=“true” on the ion-content.

Hey,

I kind of had a similar situation, but using the overflow-scroll="true" attribute. Here’s the thread:

Hey,

I have an in a modal in my app, and I would like to keep the scroll offset (position) for when the user comes back. Is it possible with a modal ?

Thanks

exactly what i needed, thank you!