react-native-gesture-handler#LongPressGestureHandler JavaScript Examples

The following examples show how to use react-native-gesture-handler#LongPressGestureHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: dragdrop.js    From actual with MIT License 6 votes vote down vote up
export function Draggable({ id, type, preview, gestures, children }) {
  let context = useContext(DragDropContext);
  let container = useRef(null);

  let _onTapHandlerStateChange = e => {
    if (e.nativeEvent.state === State.ACTIVE) {
      context.onDragStart(id, type, container.current, preview);
    } else if (e.nativeEvent.oldState === State.ACTIVE) {
      context.onDragEnd();
    }
  };

  return (
    <LongPressGestureHandler
      minDurationMs={250}
      onHandlerStateChange={_onTapHandlerStateChange}
      simultaneousHandlers={gestures.pan}
    >
      <Animated.View ref={container} style={{ flex: 1 }}>
        {children}
      </Animated.View>
    </LongPressGestureHandler>
  );
}
Example #2
Source File: ChartPath.js    From react-native-animated-charts with MIT License 6 votes vote down vote up
export function SvgComponent() {
  const {
    style,
    animatedStyle,
    height,
    width,
    animatedProps,
    props,
    onLongPressGestureEvent,
    gestureEnabled,
    longPressGestureHandlerProps,
  } = useContext(InternalContext);
  return (
    <LongPressGestureHandler
      enabled={gestureEnabled}
      maxDist={100000}
      minDurationMs={0}
      shouldCancelWhenOutside={false}
      {...longPressGestureHandlerProps}
      {...{ onGestureEvent: onLongPressGestureEvent }}
    >
      <Animated.View>
        <Svg
          height={height + 20} // temporary fix for clipped chart
          viewBox={`0 0 ${width} ${height}`}
          width={width}
        >
          <AnimatedPath
            animatedProps={animatedProps}
            {...props}
            style={[style, animatedStyle]}
          />
        </Svg>
      </Animated.View>
    </LongPressGestureHandler>
  );
}