-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feature: allow serialized animated event as onScroll #439
feature: allow serialized animated event as onScroll #439
Conversation
Hey @Jberivera, Thanks for the carefully crafted PR! In the RN thread you're referring to, it is mentioned that the issue was solved in RN 0.44. Do you have more info about that? |
ef33c9b
to
d27d7ed
Compare
Hi @bd-arc, I didn't find anything more about the issue, just that it was happening to me in react-native version 0.57.5 and if this bug is something that appears and disappears between version, this fix guarantees us that we don't need to be worried about. I squashed this last change I was wondering if it is important to try to re-set this handler references or there is no need for doing that. Thanks for your attention. |
Hey @Jberivera, Regarding your last change, I'm not a 100 % positive that forcing a component update is required. To be honest, I've never had to do that — which doesn't mean that we should avoid it entirely ;-) If you're unsure about this, I propose to keep your change in the code and to comment it. This way, if we end up discovering side effects, we could try enabling it. What do you think? |
d27d7ed
to
658c281
Compare
@bd-arc Updated. |
Using react-native-snap-carousel for more consistent scrolling, but had an issue with the main package where you can't have custom onScroll animations, found this pr meliorence/react-native-snap-carousel#439 and it seems to resolve the issue so until that is merged or not will continue using the modified code from that repo.
@Jberivera great PR! I just tested with a vertical carousel and it works no problem. |
@bd-arc Is there a blocker on this PR, can I help with something to get this merged ? |
@agarant That's nice of you to ask! The only issue has been the lack of time to work on the plugin lately. I'll update the component and merge a few PR (including this one) real soon ;-) |
Available in version |
Platforms affected
All
What does this PR do?
This PR is for allowing to pass a serializable Animated.event as an onScroll property, I was trying to spread the array of maps that use Animated.event as the first argument but react-native was just using the first item in that array of maps, so I made a fix for using or sharing the animated value passed as prop instead of the one that it's defined in the library.
What testing has been done on this change?
using a regular callback as a prop for onScroll and using an Animated.event with useNativeDriver set on
I'm going to be testing the feature listed below, to be sure this change doesn't break anything.
Tested features checklist
enableMomentum
)vertical
)activeSlideAlignment
)autoplay
)loop
)ScrollView
/FlatList
carousels (propuseScrollView
)ParallaxImage
componentPagination
componentThe next gif link is some evidence that despite that this ticket was just about using Animated.event, it is not breaking custom interpolations, so in order to show you that, I'm going to comment this block of code. Take into account that even without this fix this is not going to affect old Carousel configurations, only new ones with
onScroll={Animated.event([{ nativeEvent: { contentOffset: { x: this.translateX } } }], { useNativeDriver: true })}
as a prop, so the fix is only for those who want to use useNativeDriver and custom interpolations at same time.The next gif-bug is not the final result. see the comment above.
https://user-images.githubusercontent.com/4753246/49823369-7f02d000-fd4d-11e8-98ef-e806a5fa2916.gif
After adding commented lines back and using the same example configuration as shown below.
final result.