rn-placeholder
rn-placeholder copied to clipboard
Add useNativeDriver to shine animations
Make Shine
and ShineOverlay
animations run on the native thread. Related to this issue: https://github.com/mfrachet/rn-placeholder/issues/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
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
😄
Any update on this @stoica94 ?