From 06a89c5c68d94466f3b1a65e1341509ff392db6e Mon Sep 17 00:00:00 2001 From: Eric Denman Date: Thu, 10 Jun 2021 14:48:52 +1200 Subject: [PATCH] Prevent dismiss() from re-starting the animation if it's already running --- loupe-library/src/main/java/com/igreenwood/loupe/Loupe.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/loupe-library/src/main/java/com/igreenwood/loupe/Loupe.kt b/loupe-library/src/main/java/com/igreenwood/loupe/Loupe.kt index f65b963..439aecf 100644 --- a/loupe-library/src/main/java/com/igreenwood/loupe/Loupe.kt +++ b/loupe-library/src/main/java/com/igreenwood/loupe/Loupe.kt @@ -921,8 +921,11 @@ class Loupe(imageView: ImageView, container: ViewGroup) : View.OnTouchListener, } fun dismiss() { - // Animate down offscreen (the finish listener will call the cleanup method) - startVerticalTranslateAnimation(MIN_FLING_VELOCITY) + // Only start the animation if it's not already running. + if (!isViewTranslateAnimationRunning) { + // Animate down offscreen (the finish listener will call the cleanup method) + startVerticalTranslateAnimation(MIN_FLING_VELOCITY) + } } fun cleanup() {