Is it possible to animate Window.scrollTop

2019-06-13 14:48发布

I would like to add animate smooth, any adia?

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

标签: gwt scroll
2条回答
再贱就再见
2楼-- · 2019-06-13 15:19

You can use jQuery animate function for the same.

$('html').animate({ scrollTop: '0' });
查看更多
叛逆
3楼-- · 2019-06-13 15:19

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);
            }
    });
}-*/;
查看更多
登录 后发表回答