Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Returning to previous scroll position when going back does not work #158

Closed
jupiterplanet opened this Issue Apr 3, 2013 · 5 comments

Comments

Projects
None yet
3 participants

When I scroll down a long page go to a new page and go back to the previous page jQuery mobile restores the previous scroll position. See http://plnkr.co/i7wfKo.

  1. Scroll down to the end of the page
  2. Click on link "Page"
  3. Click on "Back"
  4. jQuery mobile restores the scroll position.

Using the jQuery mobile AngularJS adapter this does not work. See http://plnkr.co/ZXmsCW.

My issue is like this but when I scroll down to the end of the page, the back action is fired.

Contributor

tbosch commented Apr 5, 2013

Hi jupiterplanet,
thanks for reporting and the reproducible plunk. Will look into this soon.

@jupiterplanet: Could you create a plunk for this so I can reproduce it? The plunk from @jupiterplanet does not show your behavior of firing the back action...

Thanks,
Tobias

Contributor

tbosch commented Apr 15, 2013

Umh, I meant @agustinvinao: Could you create a plunk for this so I can reproduce it? The plunk from @jupiterplanet does not show your behavior of firing the back action...

Contributor

tbosch commented Apr 15, 2013

jqm sources: setLastScroll saves the current scroll position after every scroll event into $.mobile.urlHistory.getActive().lastScroll.
That value is used later by the transitions, see scrollPage = function() {...} in the transition handlers of jqm.

Our problem here is that we do not use $.mobile.urlHistory any more, and by that we also loose the saved scroll position. Need to save that value in our history too...

@tbosch tbosch closed this in 5733f36 Apr 24, 2013

Contributor

tbosch commented Apr 24, 2013

Hi,
took a while as I didn't know that html5 history popState also tries to restore the old scrolling position. In Chrome, this is AFTER the event is fired, and by this is prevented our own scroll changes...

Tobias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment