Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// 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();
!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();
}
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,