// Starts the fling animation. Called both as a response to a fling gesture and as via the // public WebView#flingScroll(int, int) API. public void flingScroll(int velocityX, int velocityY) { final int scrollX = mDelegate.getContainerViewScrollX(); final int scrollY = mDelegate.getContainerViewScrollY(); final int rangeX = computeMaximumHorizontalScrollOffset(); final int rangeY = computeMaximumVerticalScrollOffset(); mScroller.fling(scrollX, scrollY, velocityX, velocityY, 0, rangeX, 0, rangeY); mDelegate.invalidate(); }
// Called immediately before the draw to update the scroll offset. public void computeScrollAndAbsorbGlow(OverScrollGlow overScrollGlow) { final boolean stillAnimating = mScroller.computeScrollOffset(); if (!stillAnimating) return; final int oldX = mDelegate.getContainerViewScrollX(); final int oldY = mDelegate.getContainerViewScrollY(); int x = mScroller.getCurrX(); int y = mScroller.getCurrY(); int rangeX = computeMaximumHorizontalScrollOffset(); int rangeY = computeMaximumVerticalScrollOffset(); if (overScrollGlow != null) { overScrollGlow.absorbGlow(x, y, oldX, oldY, rangeX, rangeY, mScroller.getCurrVelocity()); } // The mScroller is configured not to go outside of the scrollable range, so this call // should never result in attempting to scroll outside of the scrollable region. scrollBy(x - oldX, y - oldY); mDelegate.invalidate(); }