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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useNativeDriver to shine animations #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ovistoica
Copy link

Make Shine and ShineOverlay animations run on the native thread. Related to this issue: #99

Only remaining animation on the JS side is Progressive.
I think this is still possible but I would want to start a discussion regarding this. For using translateX as the animated prop you need the width of how much to translate.

My attempts at converting Progressive were making the animation look different from the initial one because the Progressive View was the same width on all children (Left, Right or Other Media) therefore translating with 50% would look different on lines of different length and it was not possible to find the width of the PlaceHolderLine or Media to translate only by that, as the Animation Consumer was put inside the View and not on the outside.

Example
IMG_1835

In the picture above, I translated the AnimatedView with -20%, as you can see, in the Left and Right media, this shows a progress of 50% because the View is translated by 20% of its own width.

A possible solution would be to define the AnimationConsumer inside the PlaceholderLine and PlaceholderMedia so that you can pass through that context an onLayout function that can get the width of the parent.

I considered that to be a bit too much of a reimplementation, but that would solve the problem. If you give the alright for that, I would provide a different PR with this.

Until then, here is Shine and ShineOverlay 馃槃

inputRange: [START_VALUE, END_VALUE],
outputRange: ["0%", "100%"],
outputRange: ["0%", "250%"],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why 250%? 馃槉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. The width of the animated view is 40% of the parent. In order to Translate over the whole surface of the parent, we need to Translate with 2.5 of itself meaning 100% of the parent

Copy link
Owner

@mfrachet mfrachet Sep 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing the following error: https://github.com/facebook/react-native/blob/aee88b6843cea63d6aa0b5879ad6ef9da4701846/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeMap.java#L132

Screenshot_20200918-082052

Looks like % are not valid as a transform value. See the API here: https://reactnative.dev/docs/transforms#transform and I think this is the reason why I didn't rely on this when implementing, hard times 馃槄 !

Thank you for the effort on this pull requests 馃槉 馃檹

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, this is on Android, right? Hmmm... To be fair, I only tested IOS, which was working. I will look into it, when I have some more time 馃憤

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's on android :)

@lukebrandonfarrell
Copy link

Any update on this @stoica94 ?

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

Successfully merging this pull request may close these issues.

None yet

4 participants