Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<Text /> with PanResponder only works if you click exactly on the letters #2250

Open
mbaviera opened this issue Mar 28, 2024 · 0 comments
Open

Comments

@mbaviera
Copy link

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:

Gravacao.de.Tela.2024-03-28.as.07.56.37.mov
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>
  )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant