Skip to content

Commit

Permalink
Use correct ScaleType when animating same element multiple times
Browse files Browse the repository at this point in the history
When animating images in shared element transition, we change their ScaleType to an InterpolatingScaleType.
At the end of the animation we need to restore the ScaleType back to its original value but for some reason this doesn't seem to work.

The current solution recursively find the original scale type used for the destination image.

Related to #6505
  • Loading branch information
guyca committed Aug 24, 2020
1 parent 8df2a29 commit a436e21
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ class MatrixAnimator(from: View, to: View) : PropertyAnimatorCreator<ReactImageV
}

private fun getScaleType(child: View): ScalingUtils.ScaleType? {
val scaleType = (child as ReactImageView).hierarchy.actualImageScaleType
return if (scaleType is InterpolatingScaleType) scaleType.scaleTypeFrom else scaleType
return getScaleType(child as ReactImageView, child.hierarchy.actualImageScaleType!!)
}

private fun getScaleType(child: ReactImageView, scaleType: ScalingUtils.ScaleType): ScalingUtils.ScaleType? {
if (scaleType is InterpolatingScaleType) return getScaleType(child, scaleType.scaleTypeTo )
return scaleType
}

private fun calculateBounds(view: View) = Rect(0, 0, view.width, view.height)
Expand Down

0 comments on commit a436e21

Please sign in to comment.