How to use react-native-gesture-handler - 10 common examples

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 berty / berty / js / packages / components / chat / record / RecordComponent.tsx View on Github external
} else {
							try {
								;(recorder.current as any)?.on('meter', addMeteredValue)
							} catch (e) {
								console.warn(['err' + e])
							}
							setRecordingState(RecordingState.RECORDING)
						}
					})
				}

				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 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 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,
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
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 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
          })
        ]);
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 react-navigation / navigation-ex / packages / drawer / src / views / Drawer.tsx View on Github external
call([this.isSwiping], ([value]: readonly Binary[]) => {
        const { keyboardDismissMode } = this.props;

        if (value === TRUE) {
          if (keyboardDismissMode === 'on-drag') {
            Keyboard.dismiss();
          }

          this.toggleStatusBar(true);
        } else {
          this.toggleStatusBar(this.currentOpenValue);
        }
      })
    ),
    cond(
      eq(this.gestureState, State.ACTIVE),
      [
        cond(this.isSwiping, NOOP, [
          // We weren't dragging before, set it to true
          set(this.isSwiping, TRUE),
          // Also update the drag offset to the last position
          set(this.offsetX, this.position),
        ]),
        // Update position with previous offset + gesture distance
        set(
          this.position,
          add(this.offsetX, this.gestureX, this.touchDistanceFromDrawer)
        ),
        // Stop animations while we're dragging
        stopClock(this.clock),
      ],
      [
github punksta / Cat-or-dog / src / containers / DraggingFallingReanimated.js View on Github external
resetPosition = true
	) => [
		// we stop
		stopClock(clock),
		set(state.finished, 0),
		resetPosition ? set(state.position, 0) : 1,
		set(state.time, 0),
		set(state.frameTime, 0),
		set(config.toValue, toValue),
		set(config.duration, duration),
		// and we restart
		startClock(clock)
	];

	const isNotDragging = and(
		neq(gestureState, State.ACTIVE),
		neq(gestureState, State.BEGAN)
	);

	const pendingPosition = () => cond(greaterThan(state.position, 180), 360, 0);

	const pendingRotate = () =>
		cond(
			greaterThan(state.position, 180),
			sub(360, state.position),
			state.position
		);

	// 180           - 1.0
	// pendingRotate - x
	const pendingDurationP = () => divide(pendingRotate(), 180);