-
Notifications
You must be signed in to change notification settings - Fork 908
Motion: Support predictive back in Container transform #102
Conversation
Change-Id: I9adb4a48be47761dc725f67e50be872a8865587a
override fun handleOnBackPressed() { | ||
// This invokes the sharedElementReturnTransition, which is | ||
// MaterialContainerTransform. | ||
// TODO: It pops the scaleX/Y back to 1f. It would look nicer to retain the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the transition after the back gesture is committed (e.g. MaterialContainerTransform for the sharedElementReturnTransition) that is popping the scale back to 1f?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shared elements are copied into the target fragment before the transition animations start. It seems the scale and other transformations are dropped in the process. I tried using a set of ChangeTransform
(it handles scaleX/Y) and MaterialContainerTransform
, but it doesn't work for some reason.
I updated the formula below, and this is hardly unnoticeable. I think I don't care about this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the updated formulas the reset is not very noticeable at all
thanks Yuichi!
// TODO: Consider handling backEvent.touchY to reflect the vertical movement. | ||
|
||
// Scale down from 100% to 50%. | ||
val scale = (2f - progress) * 0.5f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the formula is 1F - (0.1F * progress) because the max scale is 90%
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. I suppose you mean the "min" scale.
override fun handleOnBackProgressed(backEvent: BackEventCompat) { | ||
val progress = backEvent.progress | ||
// Translate as far as 20% of finger movement. | ||
val translation = progress * background.width * 0.2f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the formula for translationX is (progress * maxXShift) for the left edge and -(progress * maxXShift) for the right edge, where maxXShift is windowWidth / 20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I didn't know we had a motion spec.
Change-Id: I8ccbc5267ecd3aae1c1179ff5a7036030896ba8a
pb.webm |
Change-Id: I8f438fe1aa25dcd452872495dd132ed62fba030e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Change-Id: I9adb4a48be47761dc725f67e50be872a8865587a