keske / react-native-easy-gestures

React Native Gestures. Support: Drag, Scale and Rotate a Component.
MIT License
173 stars 61 forks source link

Limiting the y and x axis #36

Open Ahmed-Imam opened 5 years ago

Ahmed-Imam commented 5 years ago

I want to limit the draggable components to be dragged in the above part of the screen only

<Gestures
                rotatable={false}
                 draggable={{
                        y: height/2,
                                  }}
                   scalable={{
                           min: 0.1,
                            max: 7,
                                }}/>
stokesbga commented 5 years ago

Check out my fork. still updating it, but it has a callback for onOutOfBounds and props for containerStyle etc.

Ahmed-Imam commented 5 years ago

I solved the issue temporary as follow, please share if you have a better solution or any suggestion

<Gestures
     onChange={(event) => event.touchHistory.touchBank[Platform.OS == 'ios' ? 1 : 0].currentPageY >= 300 ?
      this.setState({ Y: false }) : this.setState({ Y: true })}
      draggable={{
             y: this.state.Y,
             x: true}}>
           <Text>Test</Text>
</Gestures>