How to use the react-swipeable-views-core.constant.UNCERTAINTY_THRESHOLD function in react-swipeable-views-core

To help you get started, we’ve selected a few react-swipeable-views-core 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 oliviertassinari / react-swipeable-views / packages / react-swipeable-views / src / SwipeableViews.js View on Github external
}

    // We are not supposed to hanlde this touch move.
    if (nodeWhoClaimedTheScroll !== null && nodeWhoClaimedTheScroll !== this.rootNode) {
      return;
    }

    const { axis, children, ignoreNativeScroll, onSwitching, resistance } = this.props;
    const touch = applyRotationMatrix(event.touches[0], axis);

    // We don't know yet.
    if (this.isSwiping === undefined) {
      const dx = Math.abs(touch.pageX - this.startX);
      const dy = Math.abs(touch.pageY - this.startY);

      const isSwiping = dx > dy && dx > constant.UNCERTAINTY_THRESHOLD;

      // We let the parent handle the scroll.
      if (
        !resistance &&
        (axis === 'y' || axis === 'y-reverse') &&
        ((this.indexCurrent === 0 && this.startX < touch.pageX) ||
          (this.indexCurrent === React.Children.count(this.props.children) - 1 &&
            this.startX > touch.pageX))
      ) {
        this.isSwiping = false;
        return;
      }

      // We are likely to be swiping, let's prevent the scroll event.
      if (dx > dy && event.cancelable) {
        event.preventDefault();
github oliviertassinari / react-swipeable-views / packages / react-swipeable-views / src / SwipeableViews.js View on Github external
!resistance &&
        (axis === 'y' || axis === 'y-reverse') &&
        ((this.indexCurrent === 0 && this.startX < touch.pageX) ||
          (this.indexCurrent === React.Children.count(this.props.children) - 1 &&
            this.startX > touch.pageX))
      ) {
        this.isSwiping = false;
        return;
      }

      // We are likely to be swiping, let's prevent the scroll event.
      if (dx > dy && event.cancelable) {
        event.preventDefault();
      }

      if (isSwiping === true || dy > constant.UNCERTAINTY_THRESHOLD) {
        this.isSwiping = isSwiping;
        this.startX = touch.pageX; // Shift the starting point.

        return; // Let's wait the next touch event to move something.
      }
    }

    if (this.isSwiping !== true) {
      return;
    }

    // We are swiping, let's prevent the scroll event.
    if (event.cancelable) {
      event.preventDefault();
    }
github oliviertassinari / react-swipeable-views / native / packages / react-swipeable-views-native / src / SwipeableViews.animated.tsx View on Github external
onMoveShouldSetPanResponder: (event, gestureState) => {
        const dx = Math.abs(gestureState.dx);
        const dy = Math.abs(gestureState.dy);

        return dx > dy && dx > constant.UNCERTAINTY_THRESHOLD;
      },
      onPanResponderRelease: this.handleTouchEnd,

react-swipeable-views-core

react-swipeable-views core modules

MIT
Latest version published 4 years ago

Package Health Score

62 / 100
Full package analysis

Similar packages