Skip to content

Commit ef65bb6

Browse files
fix(android): opacity not animating when combined with rotation (#40)
setBackfaceVisibilityDependantOpacity() resets alpha to 1.0 every frame during rotation animations, overriding animated opacity. Skip the backface check when MASK_OPACITY is set — the opacity animator handles alpha directly in that case.
1 parent 0247b5d commit ef65bb6

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

android/src/main/java/com/ease/EaseView.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,10 @@ class EaseView(context: Context) : ReactViewGroup(context) {
446446
}
447447

448448
// Update backface visibility after setting initial rotation values.
449+
// Skip when opacity is animated — backface check resets alpha.
449450
// https://github.com/facebook/react-native/blob/a98aa814/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt#L967-L985
450-
if (mask and (MASK_ROTATE or MASK_ROTATE_X or MASK_ROTATE_Y) != 0) {
451+
if (mask and (MASK_ROTATE or MASK_ROTATE_X or MASK_ROTATE_Y) != 0 &&
452+
mask and MASK_OPACITY == 0) {
451453
setBackfaceVisibilityDependantOpacity()
452454
}
453455
} else if (allTransitionsNone()) {
@@ -820,7 +822,10 @@ class EaseView(context: Context) : ReactViewGroup(context) {
820822

821823
val batchId = animationBatchId
822824
pendingBatchAnimationCount++
823-
val needsBackfaceUpdate = propertyName in isRotationProperty
825+
// Only update backface visibility when opacity is NOT animated — the backface
826+
// check resets alpha, which would clobber the animated opacity value.
827+
val needsBackfaceUpdate = propertyName in isRotationProperty &&
828+
(animatedProperties and MASK_OPACITY == 0)
824829

825830
val animator = ObjectAnimator.ofFloat(this, propertyName, fromValue, toValue).apply {
826831
duration = config.duration.toLong()
@@ -880,9 +885,10 @@ class EaseView(context: Context) : ReactViewGroup(context) {
880885
val batchId = animationBatchId
881886
pendingBatchAnimationCount++
882887

883-
val needsBackfaceUpdate = viewProperty == DynamicAnimation.ROTATION ||
888+
val needsBackfaceUpdate = (viewProperty == DynamicAnimation.ROTATION ||
884889
viewProperty == DynamicAnimation.ROTATION_X ||
885-
viewProperty == DynamicAnimation.ROTATION_Y
890+
viewProperty == DynamicAnimation.ROTATION_Y) &&
891+
(animatedProperties and MASK_OPACITY == 0)
886892

887893
val dampingRatio = (config.damping / (2.0f * sqrt(config.stiffness * config.mass)))
888894
.coerceAtLeast(0.01f)

0 commit comments

Comments
 (0)