Tuesday, May 12, 2015

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

@Jens: I don't think your solution isn't working.

You mentioned I should not use id attribute, and instead use something like data-scroll-id.
I change it now to for example: <div data-id="blaMarker">...</div>, but still the browser jumps on pressing the history back button before I can process my history marker. 

Details: 
As soon as a person arrives as a certain part of the page I set a history marker (as hash) in the url, like example: 
"#NvWrkDcUsgSt?id=IdUsgSelect"​
The first part indicates the page to be shown and the id parts the section on the page. 
The target Element containing the id part: <div data-id="idUsgSelect">...</div>

So when the History change event is fired with the above history value, I stop in the GWT class History.onHashChanged() through a breakpoint, but then the browser already jumped to the position when the history marker was added to the url.

Apparently the browser will record the scroll position of the page when the url is changed and jumps back to it when it appears in the browser history during back/forward actions.
But is there anyway to ensure the browser will scroll smoothly instead of jumping ...?



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