panresponder_demo icon indicating copy to clipboard operation
panresponder_demo copied to clipboard

How to limit X axis?

Open flarocca opened this issue 7 years ago • 2 comments

Hey @Hyra !!!

I've read your post about PanResponder and I have to say it is amazing.

What I'm not being able to acomplish is to limit the X value between X1 and X2. Lets try to clarify. When the object is rendered the first time it starts in position 0, so it should never be under zero.

This is what I've tried so far:

onPanResponderGrant: (e, gestureState) => {
  let x = (this.state.pan.x._value < 0) ? 0 : this.state.pan.x._value;
  this.state.pan.setOffset({ x, y: 0 });
},

Is there any way to do that?

Thanks man!!! I really appreciate your help.

flarocca avatar Sep 13 '17 03:09 flarocca

hello, found any solution for this ?

artsx avatar Nov 16 '17 11:11 artsx

Any Updates ?

Ahmed-Imam avatar Dec 25 '18 18:12 Ahmed-Imam