diff --git a/CHANGELOG.md b/CHANGELOG.md index 10bf577..8eca877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### v1.5.1 + +* Smooth out the drag dismiss animation + ### v1.5.0 * Don't assume 24dp for the status bar size (Essential Ph-1) diff --git a/README.md b/README.md index 92885aa..07ca7d7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ To include it in your project, add this to your module's `build.gradle` file: ```groovy dependencies { ... - compile 'com.klinkerapps:drag-dismiss-activity:1.5.0' + compile 'com.klinkerapps:drag-dismiss-activity:1.5.1' } ``` diff --git a/gradle.properties b/gradle.properties index eaf33bd..2c1f325 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,16 +14,16 @@ # limitations under the License. # -GRADLE_PLUGIN_VERSION=3.0.0-beta6 -BUILD_TOOLS_VERSION=26.0.1 +GRADLE_PLUGIN_VERSION=3.0.1 +BUILD_TOOLS_VERSION=27.0.1 -ANDROID_SUPPORT_VERSION=26.0.1 +ANDROID_SUPPORT_VERSION=27.1.0 MIN_SDK=15 -TARGET_SDK=26 -COMPILE_SDK=26 +TARGET_SDK=27 +COMPILE_SDK=27 -VERSION_NAME=1.5.0 +VERSION_NAME=1.5.1 VERSION_CODE=1 GROUP=com.klinkerapps diff --git a/library/src/main/java/xyz/klinker/android/drag_dismiss/view/ElasticDragDismissFrameLayout.java b/library/src/main/java/xyz/klinker/android/drag_dismiss/view/ElasticDragDismissFrameLayout.java index a592ddc..82104ff 100644 --- a/library/src/main/java/xyz/klinker/android/drag_dismiss/view/ElasticDragDismissFrameLayout.java +++ b/library/src/main/java/xyz/klinker/android/drag_dismiss/view/ElasticDragDismissFrameLayout.java @@ -23,6 +23,7 @@ import android.graphics.RectF; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; +import android.view.MotionEvent; import android.view.View; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; @@ -63,6 +64,7 @@ public class ElasticDragDismissFrameLayout extends FrameLayout { private float totalDrag; private boolean draggingDown = false; private boolean draggingUp = false; + private int lastEventAction = Integer.MIN_VALUE; private boolean enabled = true; @@ -152,6 +154,12 @@ public void onNestedScroll(View target, int dxConsumed, int dyConsumed, } } + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + lastEventAction = ev.getAction(); + return super.onInterceptTouchEvent(ev); + } + @Override public void onStopNestedScroll(View child) { if (enabled) { @@ -162,14 +170,24 @@ public void onStopNestedScroll(View child) { fastOutSlowInInterpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in); } - getChildAt(0).animate() - .translationY(0f) - .scaleX(1f) - .scaleY(1f) - .setDuration(200L) - .setInterpolator(fastOutSlowInInterpolator) - .setListener(null) - .start(); + + if (lastEventAction == MotionEvent.ACTION_DOWN) { + // this is a 'defensive cleanup for new gestures', + // don't animate here + // see also https://github.com/nickbutcher/plaid/issues/185 + setTranslationY(0f); + setScaleX(1f); + setScaleY(1f); + } else { + getChildAt(0).animate() + .translationY(0f) + .scaleX(1f) + .scaleY(1f) + .setDuration(200L) + .setInterpolator(fastOutSlowInInterpolator) + .setListener(null) + .start(); + } ValueAnimator animator = null; if (draggingUp) {