|
|
@@ -2,31 +2,29 @@ package com.reactnativenavigation.views.element.animators
|
|
2
|
2
|
|
|
3
|
3
|
import android.animation.Animator
|
|
4
|
4
|
import android.animation.ObjectAnimator
|
|
5
|
|
-import android.graphics.Rect
|
|
6
|
5
|
import android.view.View
|
|
7
|
6
|
import com.facebook.react.views.image.ReactImageView
|
|
8
|
7
|
import com.reactnativenavigation.parse.SharedElementTransitionOptions
|
|
9
|
|
-import com.reactnativenavigation.utils.ViewUtils
|
|
10
|
8
|
import com.reactnativenavigation.utils.withDuration
|
|
11
|
9
|
import com.reactnativenavigation.utils.withInterpolator
|
|
12
|
10
|
import com.reactnativenavigation.utils.withStartDelay
|
|
13
|
11
|
|
|
14
|
|
-class ClipBoundsAnimator(from: View, to: View) : PropertyAnimatorCreator<ReactImageView>(from, to) {
|
|
|
12
|
+class RotationAnimator(from: View, to: View) : PropertyAnimatorCreator<ReactImageView>(from, to) {
|
|
|
13
|
+ private val fromRotation = from.rotation
|
|
|
14
|
+ private val toRotation = to.rotation
|
|
|
15
|
+
|
|
15
|
16
|
override fun shouldAnimateProperty(fromChild: ReactImageView, toChild: ReactImageView): Boolean {
|
|
16
|
|
- return !ViewUtils.areDimensionsEqual(from, to)
|
|
|
17
|
+ return fromRotation != toRotation
|
|
17
|
18
|
}
|
|
18
|
19
|
|
|
19
|
20
|
override fun create(options: SharedElementTransitionOptions): Animator {
|
|
20
|
|
- val startDrawingRect = Rect(); from.getDrawingRect(startDrawingRect)
|
|
21
|
|
- val endDrawingRect = Rect(); to.getDrawingRect(endDrawingRect)
|
|
22
|
|
- return ObjectAnimator.ofObject(
|
|
23
|
|
- ClipBoundsEvaluator(),
|
|
24
|
|
- startDrawingRect,
|
|
25
|
|
- endDrawingRect
|
|
26
|
|
- )
|
|
|
21
|
+ to.rotation = fromRotation
|
|
|
22
|
+ to.pivotX = 0f
|
|
|
23
|
+ to.pivotY = 0f
|
|
|
24
|
+ return ObjectAnimator
|
|
|
25
|
+ .ofFloat(to, View.ROTATION, fromRotation, toRotation)
|
|
27
|
26
|
.withDuration(options.getDuration())
|
|
28
|
27
|
.withStartDelay(options.getStartDelay())
|
|
29
|
28
|
.withInterpolator(options.interpolation.interpolator)
|
|
30
|
29
|
}
|
|
31
|
|
-
|
|
32
|
30
|
}
|