Is it possible to animate Window.scrollTop

2019-06-13 15:02发布

问题:

I would like to add animate smooth, any adia?

Window.scrollTo(0, MyPanel.getAbsoluteTop());

回答1:

You can use jQuery animate function for the same.

$('html').animate({ scrollTop: '0' });


回答2:

I was using velocity.js and JSNI call:

public static native void setAnimatedScrollTop(MyView instance, String topElementId, String scrollPanelId, int offsetPosition) /*-{
    $wnd.Velocity($wnd.document.getElementById(topElementId), 'scroll',
      {duration: 1000, offset: offsetPosition, container: $wnd.document.getElementById(scrollPanelId),
            complete: function(){
                instance.@com.project.client.views.MyView::setScrollAnimationInProgress(Z)(false);
            }
    });
}-*/;


标签: gwt scroll