diff --git a/magellan-library/src/main/java/com/wealthfront/magellan/navigation/NavigationDelegate.kt b/magellan-library/src/main/java/com/wealthfront/magellan/navigation/NavigationDelegate.kt index 35e63f1e..839d6e30 100644 --- a/magellan-library/src/main/java/com/wealthfront/magellan/navigation/NavigationDelegate.kt +++ b/magellan-library/src/main/java/com/wealthfront/magellan/navigation/NavigationDelegate.kt @@ -29,6 +29,7 @@ public open class NavigationDelegate( public var currentNavigableSetup: ((NavigableCompat) -> Unit)? = null + private var activeTransition: MagellanTransition? = null private var templatedViewMap = HashMap() protected var containerView: ScreenContainer? = null @@ -64,6 +65,7 @@ public open class NavigationDelegate( override fun onHide(context: Context) { containerView = null templatedViewMap.clear() + activeTransition = null } override fun onDestroy(context: Context) { @@ -75,6 +77,7 @@ public open class NavigationDelegate( direction: Direction, backStackOperation: (Deque) -> MagellanTransition ) { + activeTransition?.interrupt() containerView?.setInterceptTouchEvents(true) navigationPropagator.beforeNavigation() val oldBackStack = backStack.map { it.navigable } @@ -140,12 +143,14 @@ public open class NavigationDelegate( } else { NoAnimationTransition() } + activeTransition = transition transition.animate(from, to, direction) { if (context != null && containerView != null) { containerView!!.removeView(from) currentNavigable!!.transitionFinished() navigationPropagator.afterNavigation() containerView!!.setInterceptTouchEvents(false) + activeTransition = null } } } diff --git a/magellan-library/src/main/java/com/wealthfront/magellan/transitions/DefaultTransition.kt b/magellan-library/src/main/java/com/wealthfront/magellan/transitions/DefaultTransition.kt index 7e2ca88b..d5128fab 100644 --- a/magellan-library/src/main/java/com/wealthfront/magellan/transitions/DefaultTransition.kt +++ b/magellan-library/src/main/java/com/wealthfront/magellan/transitions/DefaultTransition.kt @@ -21,7 +21,7 @@ public class DefaultTransition : MagellanTransition { private var animator: Animator? = null override fun interrupt() { - animator?.end() + animator?.cancel() } override fun animate( @@ -48,15 +48,16 @@ public class DefaultTransition : MagellanTransition { ): AnimatorSet { val sign = direction.sign() val axis: Property = View.TRANSLATION_X - val toTranslation = sign * to.width + val toTranslation = sign * to.width + (from?.translationX ?: 0f) val set = AnimatorSet() if (from != null) { val fromTranslation = sign * -from.width - val fromAnimation = ObjectAnimator.ofFloat(from, axis, 0f, fromTranslation.toFloat()) + val fromAnimation = ObjectAnimator.ofFloat(from, axis, from.translationX, fromTranslation.toFloat()) set.play(fromAnimation) + set.duration = (300 * (1.0f - (from.translationX / from.width))).toLong() } - val toAnimation = ObjectAnimator.ofFloat(to, axis, toTranslation.toFloat(), 0f) + val toAnimation = ObjectAnimator.ofFloat(to, axis, toTranslation, 0f) set.play(toAnimation) set.interpolator = FastOutSlowInInterpolator() return set diff --git a/magellan-sample/src/main/java/com/wealthfront/magellan/sample/IntroStep.kt b/magellan-sample/src/main/java/com/wealthfront/magellan/sample/IntroStep.kt index 118a1144..8e755037 100644 --- a/magellan-sample/src/main/java/com/wealthfront/magellan/sample/IntroStep.kt +++ b/magellan-sample/src/main/java/com/wealthfront/magellan/sample/IntroStep.kt @@ -9,6 +9,7 @@ internal class IntroStep( ) : Step(IntroBinding::inflate) { override fun onShow(context: Context, binding: IntroBinding) { + binding.root.tag = "IntroStep" binding.learnMore.setOnClickListener { goToLearnMore() } diff --git a/magellan-sample/src/main/res/layout/learn_more.xml b/magellan-sample/src/main/res/layout/learn_more.xml index 88ef302d..7dad975e 100644 --- a/magellan-sample/src/main/res/layout/learn_more.xml +++ b/magellan-sample/src/main/res/layout/learn_more.xml @@ -6,6 +6,7 @@ android:layout_height="match_parent" android:background="@color/colorCyan" android:orientation="vertical" + android:tag="LearnMore" tools:ignore="Overdraw" >