React-native-gesture-handler: Default/Initial position for Draggable Component

Created on 9 Jun 2018  路  2Comments  路  Source: software-mansion/react-native-gesture-handler

I am using draggable component as described in Draggable Example

My parent component will pass default/initial position to draggable component as props.
How to set default/initial position for draggable component?

Most helpful comment

Hi, @HeinZawHtet
Frankly speaking, I'm not really get your issue. Animated.View's style has translate field where we could pass gesture interaction like here:

<Animated.View
          style={[
            styles.box,
            {
              transform: [
                { translateX: this._translateX },
                { translateY: this._translateY },
              ],
            },
          ]}
        />

However, you can still set left or top in style in order to get proper initial position. What's more you could set an offset this values (e.g. this._translateY.setOffset(123)) or do it like: { translateY: Animated.add(this._translateY, 123) }, if you wish to handle it "manually"
I'm not really into setting initial props as it's not matter of gesture handling but processing their results

All 2 comments

Hi, @HeinZawHtet
Frankly speaking, I'm not really get your issue. Animated.View's style has translate field where we could pass gesture interaction like here:

<Animated.View
          style={[
            styles.box,
            {
              transform: [
                { translateX: this._translateX },
                { translateY: this._translateY },
              ],
            },
          ]}
        />

However, you can still set left or top in style in order to get proper initial position. What's more you could set an offset this values (e.g. this._translateY.setOffset(123)) or do it like: { translateY: Animated.add(this._translateY, 123) }, if you wish to handle it "manually"
I'm not really into setting initial props as it's not matter of gesture handling but processing their results

I suppose your issue has been fixed. If not, please let us know

Was this page helpful?
0 / 5 - 0 ratings