Skip to content

Instantly share code, notes, and snippets.

View sebastijandumancic's full-sized avatar

Sebastijan Dumancic sebastijandumancic

View GitHub Profile
@sebastijandumancic
sebastijandumancic / panresponder.ts
Created September 23, 2019 08:21
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,
@sebastijandumancic
sebastijandumancic / ts
Created September 11, 2019 11:06
Chat head code snippet
class DraggablePerson extends React.Component<Props> {
static whyDidYouRender = false;
state: State = {
isDragging: false
};
private panResponder: PanResponderInstance;
private pan = new Animated.ValueXY() as AnimatedValue;
private position = { x: 0, y: 0 };