Canpt find variable: Extrapolation in Reanimated v2

Please help me!
Screenshot_20221001-150329
My code:

import { ScrollView, View, Text, Button } from 'react-native';
import Animated, {
  useSharedValue,
  useAnimatedStyle,
  useAnimatedScrollHandler,
  interpolate,
} from 'react-native-reanimated';

export default function SomeComponent({ children }) {
  const translationY = useSharedValue(0);

  const scrollHandler = useAnimatedScrollHandler((event) => {
    translationY.value = event.contentOffset.y;
    // console.log(translationY.value)
  });
  
  const stylez = useAnimatedStyle(() => {
    // console.log(translationY.value)
    const scale = interpolate(translationY.value, 
      [-100, 0], 
      [2, 1], 
      { extrapolateRight: Extrapolation.CLAMP }
    );

    return {
      transform: [{ scale: scale }],
    };
  });

  return (
    <View>
      <Animated.Text style={[styles.box, stylez]}>
        {translationY.value}
      </Animated.Text>
      <Animated.ScrollView 
        onScroll={scrollHandler}
        scrollEventThrottle={16}
      >
        {children}
      </Animated.ScrollView>
    </View>
  );
}

const styles = {
  box: {
    position: 'absolute',
    width: 360,
    height: 150,
    zIndex: 1000,
    backgroundColor: 'green'
  }
}

Extrapolation isn’t in your import.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.