UNPKG

react-native-graph-plus

Version:

📈 Beautiful, high-performance Graphs and Charts for React Native +

37 lines (32 loc) • 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.usePanGesture = usePanGesture; var _react = require("react"); var _reactNativeGestureHandler = require("react-native-gesture-handler"); var _reactNativeReanimated = require("react-native-reanimated"); function usePanGesture(_ref) { let { enabled, holdDuration = 300 } = _ref; const x = (0, _reactNativeReanimated.useSharedValue)(0); const y = (0, _reactNativeReanimated.useSharedValue)(0); const isPanGestureActive = (0, _reactNativeReanimated.useSharedValue)(false); const panGesture = (0, _react.useMemo)(() => _reactNativeGestureHandler.Gesture.Pan().enabled(enabled).activateAfterLongPress(holdDuration).onChange(e => { x.value = e.x; y.value = e.y; }).onStart(() => { isPanGestureActive.value = true; }).onEnd(() => { isPanGestureActive.value = false; }), [enabled, holdDuration, isPanGestureActive, x, y]); return (0, _react.useMemo)(() => ({ gesture: panGesture, isActive: isPanGestureActive, x: x, y: y }), [isPanGestureActive, panGesture, x, y]); } //# sourceMappingURL=usePanGesture.js.map