Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scrollInterpolator(index) {
- const range = [3, 2, 1, 0, -1, -2, -3];
- const inputRange = getInputRangeFromIndexes(range, index);
- const outputRange = range;
- return { inputRange, outputRange };
- }
- function animatedStyles(index, animatedValue) {
- return {
- // Funciona
- opacity: animatedValue.interpolate({
- inputRange: [-3, -2, -1, 0, 1, 2, 3],
- outputRange: [0, 0, 0, 20, 0, 0, 0],
- }),
- // Não funciona
- borderRadius: animatedValue.interpolate({
- inputRange: [-3, -2, -1, 0, 1, 2, 3],
- outputRange: [0, 0, 0, 1, 0, 0, 0],
- }),
- };
- }
- class Test extends React.Component {
- renderItem = ({ item, index }) => (
- <View style={{
- backgroundColor: 'orange', borderRadius: 8, width: SIZE + 20, height: SIZE + 20, marginHorizontal: 10,
- }}
- />
- )
- render() {
- return (
- <View style={{
- flex: 1, justifyContent: 'flex-end',
- }}
- >
- <Carousel
- data={carouselItems}
- renderItem={this.renderItem}
- itemWidth={SIZE}
- itemHeight={SIZE}
- sliderWidth={screenWidth}
- sliderHeight={SIZE}
- scrollInterpolator={scrollInterpolator}
- slideInterpolatedStyle={animatedStyles}
- firstItem={initialIndex}
- onScroll={e => console.log('!!onScroll e', e.nativeEvent)}
- useScrollView
- />
- </View>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement