Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_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,
_isPressed = () => {
const { longPress, singleTap } = this.state;
// Intentionally leave out double tap
if (longPress === State.BEGAN || singleTap === State.BEGAN) {
return true;
} else {
return false;
}
}
_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);
}
};
..._.map(itemStates, (state, index) => {
return [
cond(and(eq(state, State.BEGAN), !_.includes(ignoredItems, index)), set(this._targetPage, index)),
cond(
and(eq(this._targetPage, index), eq(state, State.END), !_.includes(ignoredItems, index)),
set(this._currentPage, index),
),
];
}),
])
render() {
const pressed = this.state.gestureHandlerState === State.BEGAN;
const style = pressed
? { backgroundColor: this.props.underlayColor }
: INACTIVE_UNDERLAY_STYLE;
return (
);
}
}
(event: PanGestureHandlerStateChangeEvent) => {
if (event.nativeEvent.state === State.BEGAN) {
setIsDragging(true);
} else if (event.nativeEvent.oldState === State.ACTIVE) {
setIsDragging(false);
translateX.setValue(0);
translateY.setValue(0);
}
},
[setIsDragging, translateX, translateY],
const scroll = (
gestureState: Value, offset: Value, translation: Value, prevTranslation: Value,
velocity: Value, lowerBound: Value, upperBound: Value, clock: Clock,
snap: (Value, Value) => Value, currentIndex: Value,
): Value => cond(
eq(gestureState, State.ACTIVE),
[
set(offset, add(offset, sub(translation, prevTranslation))),
set(prevTranslation, translation),
offset,
],
[
cond(eq(gestureState, State.BEGAN), stopClock(clock)),
set(prevTranslation, 0),
set(offset, bound(offset, lowerBound, upperBound)),
cond(eq(gestureState, State.END), set(offset, snap(clock, offset, velocity, currentIndex))),
offset,
],
);
onHandlerStateChange = event => {
if (this.touched) {
return;
}
if (event.nativeEvent.state === State.BEGAN) {
this.touched = true;
this.props.onActionPerformed();
this.fallingAnimation?.stop();
this.playDissapearAnimation();
}
};
_onHeaderHandlerStateChange = ({ nativeEvent }) => {
if (nativeEvent.oldState === State.BEGAN) {
this._lastScrollY.setValue(0)
}
this._onHandlerStateChange({ nativeEvent })
}
onHeaderHandlerStateChange = ({nativeEvent}) => {
if (nativeEvent.oldState === GestureState.BEGAN) {
this.lastScrollY.setValue(0);
this.lastScrollYValue = 0;
}
this.onHandlerStateChange({nativeEvent});
};