How to use the react-native-gesture-handler.State.FAILED function in react-native-gesture-handler

To help you get started, we’ve selected a few react-native-gesture-handler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bolan9999 / react-native-spring-scrollview / spring-scrollview / SpringScrollView.js View on Github external
_onHandlerStateChange = ({ nativeEvent: event }) => {
    // console.log("event", event);
    switch (event.state) {
      case State.BEGAN:
        this._slowDownAnimation && this._slowDownAnimation.stop();
        this._slowDownAnimation = null;
        this._transformY.extractOffset();
        break;
      case State.CANCELLED:
      case State.FAILED:
      case State.END:
        this._transformY.flattenOffset();
        this._slowDownAnimation = Animated.sequence([
          Animated.decay(this._transformY, {
            velocity: event.velocityY / 1000,
            deceleration: 0.95,
            useNativeDriver: true
          }),
          Animated.timing(this._transformY, {
            toValue: 0,
            duration: 300,
            easing: Easing.sin,
            useNativeDriver: true
          })
        ]);
          this._slowDownAnimation.start();
github mattermost / mattermost-mobile / app / components / channel_keyboard_accessory / recorder / recorder.js View on Github external
onPanHandlerStateChange = ({nativeEvent}) => {
        switch (nativeEvent.state) {
        case GestureState.UNDETERMINED:
            console.log('PAN undetermined', nativeEvent.state); // eslint-disable-line no-console
            break;
        case GestureState.FAILED:
            console.log('PAN failed', nativeEvent.state); // eslint-disable-line no-console
            break;
        case GestureState.BEGAN:
            console.log('PAN began', nativeEvent.state); // eslint-disable-line no-console
            break;
        case GestureState.CANCELLED:
            console.log('PAN cancelled', nativeEvent.state); // eslint-disable-line no-console
            break;
        case GestureState.ACTIVE:
            console.log('PAN active', nativeEvent.state); // eslint-disable-line no-console
            break;
        case GestureState.END:
            console.log('PAN end', nativeEvent.state); // eslint-disable-line no-console
            break;
        }
    };
github berty / berty / js / packages / components / chat / record / RecordComponent.tsx View on Github external
})
				}

				return
			}

			// Released
			if (e.nativeEvent.state === State.END) {
				if (recordingState === RecordingState.RECORDING) {
					setRecordingState(RecordingState.COMPLETE)
				}

				return
			}

			if (e.nativeEvent.state === State.CANCELLED || e.nativeEvent.state === State.FAILED) {
				setRecordingState(RecordingState.PENDING_CANCEL)
				return
			}
		},
		[
github punksta / Cat-or-dog / src / containers / DraggingFallingReanimated.js View on Github external
duration: duration,
		toValue: new Value(0),
		easing: Easing.linear
	};

	return block([
		cond(and(eq(gestureState, State.BEGAN), neq(config.toValue, 1)), [
			set(state.finished, 0),
			set(state.time, 0),
			set(state.frameTime, 0),
			set(config.toValue, 1),
			startClock(clock)
		]),
		cond(
			and(
				or(eq(gestureState, State.END), eq(gestureState, State.FAILED)),
				neq(config.toValue, 0)
			),
			[
				set(state.finished, 0),
				set(state.time, 0),
				set(state.frameTime, 0),
				set(config.toValue, 0),
				startClock(clock)
			]
		),
		timing(clock, state, config),
		// cond(eq(state.finished, 1), stopClock(clock)),
		interpolate(state.position, {
			inputRange: [0, 1],
			outputRange: [1, 1.3]
		})
github software-mansion / react-native-gesture-handler / Example / customable / index.js View on Github external
parseState = ({ nativeEvent: { state, oldState } }) => {
    this.setState({
      state: Object.keys(State).find(key => State[key] === state),
    });
    if (oldState === State.ACTIVE) {
      Alert.alert('Yay!');
      clearTimeout(this.timeout);
      this.timeout = false;
    }
    if (state === State.FAILED || state === State.CANCELLED) {
      this.setState({ level: 0 });
      clearTimeout(this.timeout);
      this.timeout = false;
    }
  };
github bolan9999 / react-native-spring-scrollview / src / VerticalScrollView.js View on Github external
_onHandlerStateChange = ({ nativeEvent: event }) => {
    switch (event.state) {
      case State.BEGAN:
        this._onTouchBegin();
        break;
      case State.CANCELLED:
        break;
      case State.FAILED:
      case State.END:
        this._onTouchEnd(event.translationY, event.velocityY / 1000);
    }
  };
github iyegoroff / react-native-reanimated-color-picker / src / HueSaturationWheel.tsx View on Github external
static isGestureStartedInsideCircle(
    gestureState: Animated.Node,
    startX: Animated.Node,
    startY: Animated.Node,
    thumbSize: number,
    side: number
  ) {
    const halfThumbSize = thumbSize / 2
    const center = HueSaturationWheel.center(side, thumbSize)
    const radius = center

    return (
      and(
        neq(gestureState, GestureState.UNDETERMINED),
        neq(gestureState, GestureState.FAILED),
        lessOrEq(
          sqrt(
            add(
              pow(sub(startX, center + halfThumbSize), 2),
              pow(sub(startY, center + halfThumbSize), 2)
            )
          ),
          radius + thumbSize / 1.5
        )
      )
    )
  }
github computerjazz / react-native-draggable-flatlist / index.tsx View on Github external
nativeEvent: ({ state }) => block([
        cond(and(
          neq(state, this.panGestureState),
          not(this.disabled),
        ), [
          set(this.panGestureState, state),
          cond(or(
            eq(state, GestureState.END),
            eq(state, GestureState.CANCELLED),
            eq(state, GestureState.FAILED),
          ), this.onGestureRelease),
        ]
        ),
      ])
    }
github rainbow-me / rainbow / src / components / value-chart / ValueChart.js View on Github external
state: state =>
            cond(
              or(eq(state, State.BEGAN), eq(state, State.END)),
              set(this.gestureState, state),
              delay(
                cond(
                  or(
                    neq(state, State.FAILED),
                    neq(this.panGestureState, State.ACTIVE)
                  ),
                  set(this.gestureState, state)
                ),
                100
              )
            ),
          x: x =>
github brentvatne / swipe-action-gesture-handler-experiment / SwipeActions.js View on Github external
function gestureStateFromEnum(s) {
  switch (s) {
    case State.UNDETERMINED:
      return 'UNDETERMINED';
    case State.BEGAN:
      return 'BEGAN';
    case State.FAILED:
      return 'FAILED';
    case State.CANCELLED:
      return 'CANCELLED';
    case State.ACTIVE:
      return 'ACTIVE';
    case State.END:
      return 'END';
    default:
      return `Invalid gesture state: ${s}`;
  }
}