Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animation not working on React Native 0.77 #129

Open
huanguolin opened this issue Feb 19, 2025 · 0 comments
Open

Animation not working on React Native 0.77 #129

huanguolin opened this issue Feb 19, 2025 · 0 comments

Comments

@huanguolin
Copy link

huanguolin commented Feb 19, 2025

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-text-ticker/index.js b/node_modules/react-native-text-ticker/index.js
index 0a28c78..3dec845 100644
--- a/node_modules/react-native-text-ticker/index.js
+++ b/node_modules/react-native-text-ticker/index.js
@@ -6,12 +6,9 @@ import {
   Text,
   View,
   ScrollView,
-  NativeModules,
-  findNodeHandle,
   I18nManager
 } from 'react-native'
 
-const { UIManager } = NativeModules
 
 export const TextTickAnimationType = Object.freeze({
   auto: 'auto',
@@ -202,6 +199,10 @@ export default class TextMarquee extends PureComponent {
     this.setState({ animating: true })
     this.setTimeout(async () => {
       await this.calculateMetrics()
+
+      // Wait for 'this.setState' to update 'this.state.contentFits' in 'calculateMetrics()'.
+      await new Promise(resolve => setTimeout(resolve, 100))
+
       if (!this.state.contentFits) {
         const {onScrollStart} = this.props
         if(onScrollStart && typeof onScrollStart === "function") {
@@ -233,15 +234,13 @@ export default class TextMarquee extends PureComponent {
       try {
         const measureWidth = node =>
           new Promise(async (resolve, reject) => {
-            // nodehandle is not always there, causes crash. modified to check..
-            const nodeHandle = findNodeHandle(node);
-            if (nodeHandle) {
-              UIManager.measure(nodeHandle, (x, y, w) => {
+            if (node) {
+              node.measure((x, y, w) => {
                 // console.log('Width: ' + w)
                 return resolve(w)
               })
             } else {
-              return reject('nodehandle_not_found');
+              return reject('node_not_found');
             }
           });
         const [containerWidth, textWidth] = await Promise.all([

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant