Skip to content

How to limit X axis? #3

@flarocca

Description

@flarocca

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions