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..2e8ef081 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 @@ -48,7 +48,11 @@ public class DefaultTransition : MagellanTransition { ): AnimatorSet { val sign = direction.sign() val axis: Property = View.TRANSLATION_X - val toTranslation = sign * to.width + val toTranslation = if (to.width > 0) { + sign * to.width + } else { + sign * (to.parent as View).width + } val set = AnimatorSet() if (from != null) { val fromTranslation = sign * -from.width diff --git a/magellan-library/src/test/java/com/wealthfront/magellan/transitions/DefaultTransitionTest.kt b/magellan-library/src/test/java/com/wealthfront/magellan/transitions/DefaultTransitionTest.kt index ea7d8b11..96453b26 100644 --- a/magellan-library/src/test/java/com/wealthfront/magellan/transitions/DefaultTransitionTest.kt +++ b/magellan-library/src/test/java/com/wealthfront/magellan/transitions/DefaultTransitionTest.kt @@ -2,6 +2,7 @@ package com.wealthfront.magellan.transitions import android.os.Looper.getMainLooper import android.view.View +import android.widget.FrameLayout import androidx.test.core.app.ApplicationProvider.getApplicationContext import com.google.common.truth.Truth.assertThat import com.wealthfront.magellan.Direction @@ -47,6 +48,10 @@ class DefaultTransitionTest { private fun animate(direction: Direction): MagellanTransition { val from = View(getApplicationContext()) val to = View(getApplicationContext()) + FrameLayout(getApplicationContext()).apply { + addView(from) + addView(to) + } return DefaultTransition().apply { animate(from, to, direction) { onAnimationEndCalled = true