opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

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

Closed jupiterplanet closed 11 years ago

jupiterplanet commented 11 years ago

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.

agustinvinao commented 11 years ago

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

tbosch commented 11 years ago

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

tbosch commented 11 years ago

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...

tbosch commented 11 years ago

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 commented 11 years ago

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