Skip to content

Commit

Permalink
Smooth Scroll using inertia
Browse files Browse the repository at this point in the history
  • Loading branch information
walmsley authored Feb 23, 2019
1 parent ed8026e commit be0b5d6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions loopview/src/main/java/com/weigan/loopview/LoopView.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ protected final void scrollBy(float velocityY) {
mFuture = mExecutor.scheduleWithFixedDelay(new InertiaTimerTask(this, velocityY), 0, velocityFling,
TimeUnit.MILLISECONDS);
}

public void scrollWithSpeed(float velocityY, int velocityFling) {
cancelFuture();
mFuture = mExecutor.scheduleWithFixedDelay(new InertiaTimerTask(this, velocityY), 0, velocityFling,
TimeUnit.MILLISECONDS);
}

public void cancelFuture() {
if (mFuture != null && !mFuture.isCancelled()) {
Expand Down

0 comments on commit be0b5d6

Please sign in to comment.