Skip to content

Instantly share code, notes, and snippets.

@sebastijandumancic
Created September 23, 2019 08:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastijandumancic/4ff2184aac4dd88770f6bb66f5be998f to your computer and use it in GitHub Desktop.
Save sebastijandumancic/4ff2184aac4dd88770f6bb66f5be998f to your computer and use it in GitHub Desktop.
PanResponder example
constructor(props: Props) {
super(props);
this.pan.addListener((value) => this.position = value);
this.panResponder = PanResponder.create({
onMoveShouldSetPanResponder: (evt, gestureState) => true,
onPanResponderGrant: () => {
this.pan.setOffset({
x: this.position.x,
y: this.position.y
});
this.pan.setValue({ x: 0, y: 0 });
},
// Move object while onPress is active. Snapping is handled later.
onPanResponderMove: Animated.event([
null, { dx: this.pan.x, dy: this.pan.y }
]),
// Handle swiper behaviour after object is released.
onPanResponderRelease: (e, { dx, dy, vx }) => {
// Fix jumping when moving the object second time.
this.pan.flattenOffset();
// Send ending position to parent component.
this.props.calculateOverlapping(dx, dy, this.props.person.id);
// Animate springy tuff.
Animated.spring(this.pan, { toValue: { x: 0, y: 0 } }).start();
}
});
}
@fukemy
Copy link

fukemy commented Jul 6, 2023

Hi, I stucking in click in any bubble then expand a ChatView + move/show all bubble to top of screen like Messenger. Do you have any solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment