Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public open class NavigationDelegate(

public var currentNavigableSetup: ((NavigableCompat) -> Unit)? = null

private var activeTransition: MagellanTransition? = null
private var templatedViewMap = HashMap<NavigableCompat, View>()

protected var containerView: ScreenContainer? = null
Expand Down Expand Up @@ -64,6 +65,7 @@ public open class NavigationDelegate(
override fun onHide(context: Context) {
containerView = null
templatedViewMap.clear()
activeTransition = null
}

override fun onDestroy(context: Context) {
Expand All @@ -75,6 +77,7 @@ public open class NavigationDelegate(
direction: Direction,
backStackOperation: (Deque<NavigationEvent>) -> MagellanTransition
) {
activeTransition?.interrupt()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null out activeTransition after this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

containerView?.setInterceptTouchEvents(true)
navigationPropagator.beforeNavigation()
val oldBackStack = backStack.map { it.navigable }
Expand Down Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DefaultTransition : MagellanTransition {
private var animator: Animator? = null

override fun interrupt() {
animator?.end()
animator?.cancel()
}

override fun animate(
Expand All @@ -48,15 +48,16 @@ public class DefaultTransition : MagellanTransition {
): AnimatorSet {
val sign = direction.sign()
val axis: Property<View, Float> = 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal class IntroStep(
) : Step<IntroBinding>(IntroBinding::inflate) {

override fun onShow(context: Context, binding: IntroBinding) {
binding.root.tag = "IntroStep"
binding.learnMore.setOnClickListener {
goToLearnMore()
}
Expand Down
1 change: 1 addition & 0 deletions magellan-sample/src/main/res/layout/learn_more.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
android:layout_height="match_parent"
android:background="@color/colorCyan"
android:orientation="vertical"
android:tag="LearnMore"
tools:ignore="Overdraw"
>

Expand Down
Loading