Tuesday, May 5, 2015

How to do smooth scrolling on browser back/next button on same-page navigation?

I have a sticky top menu with menu items that perform smooth scrolling (through GreenSock) to a certain page location (I stay on the same page all the time).
It will also add a History token for every unique page location.
That works fine, it scrolls smooth and the back/next browser buttons work "well".

However, no smooth scrolling occurs when the back/next browser buttons are used as the browser will jump to the previous location immediately, before even History.onHasChanged() is called (detected through a breakpoint) :(

In my History handler I calculate the required scrolling distance, which is zero because the browser already jumped (scrolled) to the previous page location.
How can I perform the smooth scrolling when the browser  back/next buttons are used?

Is there any way, to disable this browser behavior? (cancel the browser back/next event), or replace the browser back/next behavior?


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment