Skip to content

Animating a <Rect> #2559

Answered by jakex7
dcorbin asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @dcorbin, all the attributes you mentioned can be animated without requiring any extra effort.

Reanimated example

import React from 'react';
import {Rect, Svg} from 'react-native-svg';
import Animated, {
  useSharedValue,
  useAnimatedProps,
  interpolate,
  withTiming,
  interpolateColor,
} from 'react-native-reanimated';

const AnimatedRect = Animated.createAnimatedComponent(Rect);
function ReanimatedExample() {
  const animationProgress = useSharedValue(0);
  const animatedProps = useAnimatedProps(() => {
    return {
      x: interpolate(animationProgress.value, [0, 1], [0, 100]),
      y: interpolate(animationProgress.value, [0, 1], [0, 100]),
      rx: interpolate(animationProgress.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jakex7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants