Skip to content

Commit

Permalink
fix box being stuck on bottom and top as article goes back to base po…
Browse files Browse the repository at this point in the history
…sition
  • Loading branch information
klinker41 committed Nov 12, 2016
1 parent bbf72ed commit e998e80
Showing 1 changed file with 31 additions and 0 deletions.
Expand Up @@ -16,6 +16,7 @@

package xyz.klinker.android.article.view;

import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
Expand Down Expand Up @@ -172,6 +173,36 @@ public void onStopNestedScroll(View child) {
.setInterpolator(fastOutSlowInInterpolator)
.setListener(null)
.start();

ValueAnimator animator = null;
if (draggingUp) {
animator = ValueAnimator.ofFloat(draggingBackground.top,
draggingBackground.bottom);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
draggingBackground.top = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
} else if (draggingDown) {
animator = ValueAnimator.ofFloat(draggingBackground.bottom,
draggingBackground.top);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
draggingBackground.bottom = (float) valueAnimator.getAnimatedValue();
invalidate();
}
});
}

if (animator != null) {
animator.setInterpolator(fastOutSlowInInterpolator);
animator.setDuration(200L);
animator.start();
}

totalDrag = 0;
draggingDown = draggingUp = false;
dispatchDragCallback(0f, 0f, 0f, 0f);
Expand Down

0 comments on commit e998e80

Please sign in to comment.