Is it possible to get the value of a PanGestureHandler x/y? I鈥檓 working on a Slider component and I need the value as it鈥檚 being dragged.
This IS possible! It鈥檚 just an Animated.event() which accepts an object as the second arg which contains an async listener. If anyone is interested and not sure what I mean it looks like:
this._onGestureEvent = Animated.event(
[
{
nativeEvent: {
translationX: this._translateX,
},
},
],
{
useNativeDriver: true,
listener: e => {
this.setState({ x: Math.floor(e.nativeEvent.translationX) });
},
},
);
@zachgibson you can also do sth like:
this._translateX.addListener(value => console.log("VALUE", value))
Most helpful comment
This IS possible! It鈥檚 just an
Animated.event()which accepts an object as the second arg which contains an async listener. If anyone is interested and not sure what I mean it looks like: