You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each player has 13 cards and in every turn they can pick and discard from the remaining cards.
And they can group cards, drag and change the ordering of cards at any time.
In my first attempt, I change their positions in a global state(zustand), and based on the changes in global state, individual cards use withTiming to animate the position change.
Performance issue as changing the position of multiple cards together schedule 13 different withTiming calls from JS thread.
As per my understanding(and some chatgpt), if I can call all 10 withTimings from a single runOnUI function, then the performance hit will be low as we are calling the withTiming from UI thread directly.
Based on this conjecture - I tried to use makeMutable to create sharedValue for all cards and stored that in an object outside react. But this has its own problems -
The object that holds sharedValue positions for all cards itself is not a sharedValue. Hence, I am not able to get its latest value in UI thread
If I make it a sharedValue too, I am not able to connect useAnimatedStyle of each card to their position.
Also, I am not able to properly update sharedValue value of corresponding to a key in sharedValue object.
Can anyone suggest what would be the optimal way to handle this case. As low end android devices are feeling very laggy?
Here is my latest try to solve this problem, but I am not making any progress as after converting currentPosition to a sharedValue object, registerSharedCard is not working properly and I am not able to link useAnimatedStyle of a card to its sharedValue properly.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context -
As per my understanding(and some chatgpt), if I can call all 10 withTimings from a single runOnUI function, then the performance hit will be low as we are calling the withTiming from UI thread directly.
Based on this conjecture - I tried to use makeMutable to create sharedValue for all cards and stored that in an object outside react. But this has its own problems -
Can anyone suggest what would be the optimal way to handle this case. As low end android devices are feeling very laggy?
Here is my latest try to solve this problem, but I am not making any progress as after converting currentPosition to a sharedValue object, registerSharedCard is not working properly and I am not able to link useAnimatedStyle of a card to its sharedValue properly.
and here's how I am using the useAnimatedStyle -
Beta Was this translation helpful? Give feedback.
All reactions