import React, {useRef} from 'react'; import { Animated, PanResponder, TouchableWithoutFeedback, View, } from 'react-native'; import {G, Line, Path, Polyline, Svg, Text} from 'react-native-svg'; const AnimatedSvg = Animated.createAnimatedComponent(Svg); const zeroDelta = {x: 0, y: 0}; const PanExample = () => { const xy = useRef(new Animated.ValueXY()).current; let offset = zeroDelta; xy.addListener(flatOffset => { offset = flatOffset; }); const panResponder = useRef( PanResponder.create({ onStartShouldSetPanResponder: () => true, onMoveShouldSetPanResponderCapture: () => true, onPanResponderGrant: () => { xy.setOffset(offset); xy.setValue(zeroDelta); }, onPanResponderMove: Animated.event([null, {dx: xy.x, dy: xy.y}], { useNativeDriver: false, }), onPanResponderRelease: () => { xy.flattenOffset(); }, }), ).current; const panStyle = { transform: xy.getTranslateTransform(), }; return ( STAR ); }; PanExample.title = 'Bind PanResponder on the SVG Shape'; const icon = ( ); const shouldBeRenderInView = true; const samples = [PanExample]; export {icon, samples, shouldBeRenderInView};