Browse Source

Animate textChange when location on screen is different

Only text size was taken into account
Guy Carmeli 6 years ago
parent
commit
a7d7f21a7e

+ 6
- 1
lib/android/app/src/main/java/com/reactnativenavigation/views/element/animators/TextChangeAnimator.java View File

1
 package com.reactnativenavigation.views.element.animators;
1
 package com.reactnativenavigation.views.element.animators;
2
 
2
 
3
 import android.animation.Animator;
3
 import android.animation.Animator;
4
+import android.graphics.Point;
4
 import android.widget.TextView;
5
 import android.widget.TextView;
5
 
6
 
6
 import com.facebook.react.views.text.ReactTextView;
7
 import com.facebook.react.views.text.ReactTextView;
8
+import com.reactnativenavigation.utils.ViewUtils;
7
 import com.reactnativenavigation.views.element.Element;
9
 import com.reactnativenavigation.views.element.Element;
8
 import com.shazam.android.widget.text.reflow.ReflowTextAnimatorHelper;
10
 import com.shazam.android.widget.text.reflow.ReflowTextAnimatorHelper;
9
 
11
 
17
 
19
 
18
     @Override
20
     @Override
19
     protected boolean shouldAnimateProperty(ReactTextView fromChild, ReactTextView toChild) {
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
     @Override
28
     @Override