瀏覽代碼

Animate textChange when location on screen is different

Only text size was taken into account
Guy Carmeli 6 年之前
父節點
當前提交
a7d7f21a7e

+ 6
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/element/animators/TextChangeAnimator.java 查看文件

@@ -1,9 +1,11 @@
1 1
 package com.reactnativenavigation.views.element.animators;
2 2
 
3 3
 import android.animation.Animator;
4
+import android.graphics.Point;
4 5
 import android.widget.TextView;
5 6
 
6 7
 import com.facebook.react.views.text.ReactTextView;
8
+import com.reactnativenavigation.utils.ViewUtils;
7 9
 import com.reactnativenavigation.views.element.Element;
8 10
 import com.shazam.android.widget.text.reflow.ReflowTextAnimatorHelper;
9 11
 
@@ -17,7 +19,10 @@ public class TextChangeAnimator extends PropertyAnimatorCreator<ReactTextView> {
17 19
 
18 20
     @Override
19 21
     protected boolean shouldAnimateProperty(ReactTextView fromChild, ReactTextView toChild) {
20
-        return getTextSize(fromChild) != getTextSize(toChild);
22
+        Point fromXy = ViewUtils.getLocationOnScreen(from.getChild());
23
+        Point toXy = ViewUtils.getLocationOnScreen(to.getChild());
24
+        return getTextSize(fromChild) != getTextSize(toChild) ||
25
+               !fromXy.equals(toXy.x, toXy.y);
21 26
     }
22 27
 
23 28
     @Override