I wouldn't recommend disabling the back/next behavior. For your case, you could save the scroll position of each View (using a ScrollHandler to catch the events), and when the History is changed, scroll to the current View position (or to the top if the View is a new one) using Window.moveTo, or another method from your library.
Something like this:
For a library to handle History tokens and page navigation that a look at this post. ;-)
On Tuesday, May 5, 2015 at 8:51:25 AM UTC-3, Ed wrote:
-- Something like this:
private Map<String, Point> scrollPositions = new HashMap<>();
Window.addWindowScrollHandler(new Window.ScrollHandler(){
@Override
public void onWindowScroll(Window.ScrollEvent event){
scrollPositions.put(History.getToken(), new Point(event.getScrollLeft(), event.getScrollTop()));
}
});
History.addValueChangeHandler(new ValueChangeHandler<String>(){
@Override
public void onValueChange(ValueChangeEvent<String> event){
Point p = scrollPositions.get(event.getValue());
if (p == null) p = new Point(0,0);
Window.moveTo(p.getX(), p.getY()); //or something else from your lib
}
});
For a library to handle History tokens and page navigation that a look at this post. ;-)
On Tuesday, May 5, 2015 at 8:51:25 AM UTC-3, Ed wrote:
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