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

Add animationValue to renderItem #89

Closed
gxxgcn opened this issue Jan 8, 2022 · 0 comments
Closed

Add animationValue to renderItem #89

gxxgcn opened this issue Jan 8, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@gxxgcn
Copy link
Collaborator

gxxgcn commented Jan 8, 2022

It is required when someone customize item animations outside of Carousel. For example

const MaskView = (props: { animationValue: SharedValue<number> }) => {
  const animatedStyle = useAnimatedStyle(() => {
    const backgroundColor = interinterpolateColor(
      props.animationValue.value,
      [-1, 0, 1],
      ['#000', 'transparent', '#000'],
    );
    return {
        backgroundColor,
    };
  }, []);

  return <Animated.View style={animatedStyle} />
}

<Carousel
  ...
  renderItem={({ animationValue }) => {
    return (
      <View>
        <Item />
        <MaskView animationValue={animationValue} />
      </View>
    );
  }}
/>
@gxxgcn gxxgcn added the enhancement New feature or request label Jan 8, 2022
gxxgcn added a commit that referenced this issue Jan 8, 2022
BREAKING CHANGE: Remove the parameter of `renderItem` and change it to `info` object

#89
gxxgcn added a commit that referenced this issue Jan 8, 2022
@dohooo dohooo closed this as completed Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants