Juan Reina Pascual
Juan Reina Pascual

Reputation: 4608

Is it possible to animate Window.scrollTop

I would like to add animate smooth, any adia?

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

Upvotes: 0

Views: 418

Answers (2)

Gaurav Sharma
Gaurav Sharma

Reputation: 36

You can use jQuery animate function for the same.

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

Upvotes: 1

alexp
alexp

Reputation: 797

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(){
                [email protected]::setScrollAnimationInProgress(Z)(false);
            }
    });
}-*/;

Upvotes: 0

Related Questions