software-mansion / software-mansion/react-native-svg
<Text /> with PanResponder only works if you click exactly on the letters
Open
Nobody has claimed this yet.
Question
- Dominant language
- TypeScript
- Stars
- 8k
- Forks
- 1.2k
- Avg merge
- 10d 9h
- Merged PRs (30d)
- 2
Description
Hello, I'm using PanResponder to move a text tag, but it only works if you click exactly on the letters in the text, e.g if I click on the space between the letters T and E below, the text does not move:
const AnimatedG = Animated.createAnimatedComponent(G);
const panResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onPanResponderGrant: () => {
position.setOffset(position.__getValue())
},
onPanResponderMove: Animated.event([
null,
{ dx: position.x, dy: position.y },
], { useNativeDriver: false }),
})
const { top: y, left: x } = position.getLayout()
return (
<View style={{ flex: 1 }}>
<Svg
width={width}
height={height}
>
<AnimatedG
transform={[{ translateX: x }, { translateY: y }]}
{...panResponder.panHandlers}
>
<Text
fill={fontColor}
fontSize={40}
strokeWidth="3"
stroke={fontColor}
transform={{
translateX: 120, // initial position
translateY: 100,
}}
>
{'Test'}
</Text>
</AnimatedG>
</Svg>
</View>
)
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the report with AnimatedG, PanResponder, and the nested Text example. No files or tests are named, so trace the interaction handling for G and Text first; done means dragging works when the gesture starts in the whitespace between the rendered letters, not only on the letter shapes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100