feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,654 @@
var _Reanimated$default$c, _Reanimated$default;
import React, { useContext, useEffect, useRef, useState } from 'react';
import { BaseGesture, CALLBACK_TYPE } from './gesture';
import { Reanimated } from './reanimatedWrapper';
import { registerHandler, unregisterHandler } from '../handlersRegistry';
import RNGestureHandlerModule from '../../RNGestureHandlerModule';
import { baseGestureHandlerWithMonitorProps, filterConfig, findNodeHandle, scheduleFlushOperations } from '../gestureHandlerCommon';
import { GestureStateManager } from './gestureStateManager';
import { flingGestureHandlerProps } from '../FlingGestureHandler';
import { forceTouchGestureHandlerProps } from '../ForceTouchGestureHandler';
import { longPressGestureHandlerProps } from '../LongPressGestureHandler';
import { panGestureHandlerProps, panGestureHandlerCustomNativeProps } from '../PanGestureHandler';
import { tapGestureHandlerProps } from '../TapGestureHandler';
import { hoverGestureHandlerProps } from './hoverGesture';
import { State } from '../../State';
import { TouchEventType } from '../../TouchEventType';
import { ActionType } from '../../ActionType';
import { isFabric, isJestEnv, tagMessage } from '../../utils';
import { getReactNativeVersion } from '../../getReactNativeVersion';
import { getShadowNodeFromRef } from '../../getShadowNodeFromRef';
import { Platform } from 'react-native';
import { onGestureHandlerEvent } from './eventReceiver';
import { RNRenderer } from '../../RNRenderer';
import { isNewWebImplementationEnabled } from '../../EnableNewWebImplementation';
import { nativeViewGestureHandlerProps } from '../NativeViewGestureHandler';
import GestureHandlerRootViewContext from '../../GestureHandlerRootViewContext';
import { ghQueueMicrotask } from '../../ghQueueMicrotask';
const ALLOWED_PROPS = [...baseGestureHandlerWithMonitorProps, ...tapGestureHandlerProps, ...panGestureHandlerProps, ...panGestureHandlerCustomNativeProps, ...longPressGestureHandlerProps, ...forceTouchGestureHandlerProps, ...flingGestureHandlerProps, ...hoverGestureHandlerProps, ...nativeViewGestureHandlerProps];
function convertToHandlerTag(ref) {
if (typeof ref === 'number') {
return ref;
} else if (ref instanceof BaseGesture) {
return ref.handlerTag;
} else {
var _ref$current$handlerT, _ref$current;
// @ts-ignore in this case it should be a ref either to gesture object or
// a gesture handler component, in both cases handlerTag property exists
return (_ref$current$handlerT = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.handlerTag) !== null && _ref$current$handlerT !== void 0 ? _ref$current$handlerT : -1;
}
}
function extractValidHandlerTags(interactionGroup) {
var _interactionGroup$map, _interactionGroup$map2;
return (_interactionGroup$map = interactionGroup === null || interactionGroup === void 0 ? void 0 : (_interactionGroup$map2 = interactionGroup.map(convertToHandlerTag)) === null || _interactionGroup$map2 === void 0 ? void 0 : _interactionGroup$map2.filter(tag => tag > 0)) !== null && _interactionGroup$map !== void 0 ? _interactionGroup$map : [];
}
function dropHandlers(preparedGesture) {
for (const handler of preparedGesture.config) {
RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);
unregisterHandler(handler.handlerTag, handler.config.testId);
}
scheduleFlushOperations();
}
function checkGestureCallbacksForWorklets(gesture) {
// if a gesture is explicitly marked to run on the JS thread there is no need to check
// if callbacks are worklets as the user is aware they will be ran on the JS thread
if (gesture.config.runOnJS) {
return;
}
const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);
const areSomeWorklets = gesture.handlers.isWorklet.includes(true); // if some of the callbacks are worklets and some are not, and the gesture is not
// explicitly marked with `.runOnJS(true)` show an error
if (areSomeNotWorklets && areSomeWorklets) {
console.error(tagMessage(`Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`));
}
}
function attachHandlers({
preparedGesture,
gestureConfig,
gesture,
viewTag,
webEventHandlersRef,
mountedRef
}) {
if (!preparedGesture.firstExecution) {
gestureConfig.initialize();
} else {
preparedGesture.firstExecution = false;
} // use queueMicrotask to extract handlerTags, because all refs should be initialized
// when it's ran
ghQueueMicrotask(() => {
if (!mountedRef.current) {
return;
}
gestureConfig.prepare();
});
for (const handler of gesture) {
checkGestureCallbacksForWorklets(handler);
RNGestureHandlerModule.createGestureHandler(handler.handlerName, handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS));
registerHandler(handler.handlerTag, handler, handler.config.testId);
} // use queueMicrotask to extract handlerTags, because all refs should be initialized
// when it's ran
ghQueueMicrotask(() => {
if (!mountedRef.current) {
return;
}
for (const handler of gesture) {
let requireToFail = [];
if (handler.config.requireToFail) {
requireToFail = extractValidHandlerTags(handler.config.requireToFail);
}
let simultaneousWith = [];
if (handler.config.simultaneousWith) {
simultaneousWith = extractValidHandlerTags(handler.config.simultaneousWith);
}
let blocksHandlers = [];
if (handler.config.blocksHandlers) {
blocksHandlers = extractValidHandlerTags(handler.config.blocksHandlers);
}
RNGestureHandlerModule.updateGestureHandler(handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS, {
simultaneousHandlers: simultaneousWith,
waitFor: requireToFail,
blocksHandlers: blocksHandlers
}));
}
scheduleFlushOperations();
});
preparedGesture.config = gesture;
for (const gesture of preparedGesture.config) {
const actionType = gesture.shouldUseReanimated ? ActionType.REANIMATED_WORKLET : ActionType.JS_FUNCTION_NEW_API;
if (Platform.OS === 'web') {
RNGestureHandlerModule.attachGestureHandler(gesture.handlerTag, viewTag, ActionType.JS_FUNCTION_OLD_API, // ignored on web
webEventHandlersRef);
} else {
RNGestureHandlerModule.attachGestureHandler(gesture.handlerTag, viewTag, actionType);
}
}
if (preparedGesture.animatedHandlers) {
const isAnimatedGesture = g => g.shouldUseReanimated;
preparedGesture.animatedHandlers.value = gesture.filter(isAnimatedGesture).map(g => g.handlers);
}
}
function updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef) {
gestureConfig.prepare();
for (let i = 0; i < gesture.length; i++) {
const handler = preparedGesture.config[i];
checkGestureCallbacksForWorklets(handler); // only update handlerTag when it's actually different, it may be the same
// if gesture config object is wrapped with useMemo
if (gesture[i].handlerTag !== handler.handlerTag) {
gesture[i].handlerTag = handler.handlerTag;
gesture[i].handlers.handlerTag = handler.handlerTag;
}
} // use queueMicrotask to extract handlerTags, because when it's ran, all refs should be updated
// and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
// in case of external relations)
ghQueueMicrotask(() => {
if (!mountedRef.current) {
return;
}
for (let i = 0; i < gesture.length; i++) {
const handler = preparedGesture.config[i];
handler.config = gesture[i].config;
handler.handlers = gesture[i].handlers;
const requireToFail = extractValidHandlerTags(handler.config.requireToFail);
const simultaneousWith = extractValidHandlerTags(handler.config.simultaneousWith);
RNGestureHandlerModule.updateGestureHandler(handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS, {
simultaneousHandlers: simultaneousWith,
waitFor: requireToFail
}));
registerHandler(handler.handlerTag, handler, handler.config.testId);
}
if (preparedGesture.animatedHandlers) {
var _preparedGesture$anim;
const previousHandlersValue = (_preparedGesture$anim = preparedGesture.animatedHandlers.value) !== null && _preparedGesture$anim !== void 0 ? _preparedGesture$anim : [];
const newHandlersValue = preparedGesture.config.filter(g => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI
.map(g => g.handlers); // if amount of gesture configs changes, we need to update the callbacks in shared value
let shouldUpdateSharedValue = previousHandlersValue.length !== newHandlersValue.length;
if (!shouldUpdateSharedValue) {
// if the amount is the same, we need to check if any of the configs inside has changed
for (let i = 0; i < newHandlersValue.length; i++) {
if ( // we can use the `gestureId` prop as it's unique for every config instance
newHandlersValue[i].gestureId !== previousHandlersValue[i].gestureId) {
shouldUpdateSharedValue = true;
break;
}
}
}
if (shouldUpdateSharedValue) {
preparedGesture.animatedHandlers.value = newHandlersValue;
}
}
scheduleFlushOperations();
});
}
function needsToReattach(preparedGesture, gesture) {
if (gesture.length !== preparedGesture.config.length) {
return true;
}
for (let i = 0; i < gesture.length; i++) {
if (gesture[i].handlerName !== preparedGesture.config[i].handlerName || gesture[i].shouldUseReanimated !== preparedGesture.config[i].shouldUseReanimated) {
return true;
}
}
return false;
}
function isStateChangeEvent(event) {
'worklet'; // @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point
return event.oldState != null;
}
function isTouchEvent(event) {
'worklet';
return event.eventType != null;
}
function getHandler(type, gesture) {
'worklet';
switch (type) {
case CALLBACK_TYPE.BEGAN:
return gesture.onBegin;
case CALLBACK_TYPE.START:
return gesture.onStart;
case CALLBACK_TYPE.UPDATE:
return gesture.onUpdate;
case CALLBACK_TYPE.CHANGE:
return gesture.onChange;
case CALLBACK_TYPE.END:
return gesture.onEnd;
case CALLBACK_TYPE.FINALIZE:
return gesture.onFinalize;
case CALLBACK_TYPE.TOUCHES_DOWN:
return gesture.onTouchesDown;
case CALLBACK_TYPE.TOUCHES_MOVE:
return gesture.onTouchesMove;
case CALLBACK_TYPE.TOUCHES_UP:
return gesture.onTouchesUp;
case CALLBACK_TYPE.TOUCHES_CANCELLED:
return gesture.onTouchesCancelled;
}
}
function touchEventTypeToCallbackType(eventType) {
'worklet';
switch (eventType) {
case TouchEventType.TOUCHES_DOWN:
return CALLBACK_TYPE.TOUCHES_DOWN;
case TouchEventType.TOUCHES_MOVE:
return CALLBACK_TYPE.TOUCHES_MOVE;
case TouchEventType.TOUCHES_UP:
return CALLBACK_TYPE.TOUCHES_UP;
case TouchEventType.TOUCHES_CANCELLED:
return CALLBACK_TYPE.TOUCHES_CANCELLED;
}
return CALLBACK_TYPE.UNDEFINED;
}
function runWorklet(type, gesture, event, ...args) {
'worklet';
const handler = getHandler(type, gesture);
if (gesture.isWorklet[type]) {
// @ts-ignore Logic below makes sure the correct event is send to the
// correct handler.
handler === null || handler === void 0 ? void 0 : handler(event, ...args);
} else if (handler) {
console.warn(tagMessage('Animated gesture callback must be a worklet'));
}
}
function useAnimatedGesture(preparedGesture, needsRebuild) {
if (!Reanimated) {
return;
} // Hooks are called conditionally, but the condition is whether the
// react-native-reanimated is installed, which shouldn't change while running
// eslint-disable-next-line react-hooks/rules-of-hooks
const sharedHandlersCallbacks = Reanimated.useSharedValue(null); // eslint-disable-next-line react-hooks/rules-of-hooks
const lastUpdateEvent = Reanimated.useSharedValue([]); // not every gesture needs a state controller, init them lazily
const stateControllers = [];
const callback = event => {
'worklet';
const currentCallback = sharedHandlersCallbacks.value;
if (!currentCallback) {
return;
}
for (let i = 0; i < currentCallback.length; i++) {
const gesture = currentCallback[i];
if (event.handlerTag === gesture.handlerTag) {
if (isStateChangeEvent(event)) {
if (event.oldState === State.UNDETERMINED && event.state === State.BEGAN) {
runWorklet(CALLBACK_TYPE.BEGAN, gesture, event);
} else if ((event.oldState === State.BEGAN || event.oldState === State.UNDETERMINED) && event.state === State.ACTIVE) {
runWorklet(CALLBACK_TYPE.START, gesture, event);
lastUpdateEvent.value[gesture.handlerTag] = undefined;
} else if (event.oldState !== event.state && event.state === State.END) {
if (event.oldState === State.ACTIVE) {
runWorklet(CALLBACK_TYPE.END, gesture, event, true);
}
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, true);
} else if ((event.state === State.FAILED || event.state === State.CANCELLED) && event.state !== event.oldState) {
if (event.oldState === State.ACTIVE) {
runWorklet(CALLBACK_TYPE.END, gesture, event, false);
}
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);
}
} else if (isTouchEvent(event)) {
if (!stateControllers[i]) {
stateControllers[i] = GestureStateManager.create(event.handlerTag);
}
if (event.eventType !== TouchEventType.UNDETERMINED) {
runWorklet(touchEventTypeToCallbackType(event.eventType), gesture, event, stateControllers[i]);
}
} else {
runWorklet(CALLBACK_TYPE.UPDATE, gesture, event);
if (gesture.onChange && gesture.changeEventCalculator) {
var _gesture$changeEventC;
runWorklet(CALLBACK_TYPE.CHANGE, gesture, (_gesture$changeEventC = gesture.changeEventCalculator) === null || _gesture$changeEventC === void 0 ? void 0 : _gesture$changeEventC.call(gesture, event, lastUpdateEvent.value[gesture.handlerTag]));
lastUpdateEvent.value[gesture.handlerTag] = event;
}
}
}
}
}; // eslint-disable-next-line react-hooks/rules-of-hooks
const event = Reanimated.useEvent(callback, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], needsRebuild);
preparedGesture.animatedEventHandler = event;
preparedGesture.animatedHandlers = sharedHandlersCallbacks;
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateDetectorChildren(ref) {
// finds the first native view under the Wrap component and traverses the fiber tree upwards
// to check whether there is more than one native view as a pseudo-direct child of GestureDetector
// i.e. this is not ok:
// Wrap
// |
// / \
// / \
// / \
// / \
// NativeView NativeView
//
// but this is fine:
// Wrap
// |
// NativeView
// |
// / \
// / \
// / \
// / \
// NativeView NativeView
if (__DEV__ && Platform.OS !== 'web') {
const REACT_NATIVE_VERSION = getReactNativeVersion(); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const wrapType = REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0 ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ref._reactInternals.elementType : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ref._reactInternalFiber.elementType; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
let instance = RNRenderer.findHostInstance_DEPRECATED(ref)._internalFiberInstanceHandleDEV; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
while (instance && instance.elementType !== wrapType) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (instance.sibling) {
throw new Error('GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.');
} // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
instance = instance.return;
}
}
}
const applyUserSelectProp = (userSelect, gesture) => {
for (const g of gesture.toGestureArray()) {
g.config.userSelect = userSelect;
}
};
const applyEnableContextMenuProp = (enableContextMenu, gesture) => {
for (const g of gesture.toGestureArray()) {
g.config.enableContextMenu = enableContextMenu;
}
};
const applyTouchActionProp = (touchAction, gesture) => {
for (const g of gesture.toGestureArray()) {
g.config.touchAction = touchAction;
}
};
/**
* `GestureDetector` is responsible for creating and updating native gesture handlers based on the config of provided gesture.
*
* ### Props
* - `gesture`
* - `userSelect` (**Web only**)
* - `enableContextMenu` (**Web only**)
* - `touchAction` (**Web only**)
*
* ### Remarks
* - Gesture Detector will use first native view in its subtree to recognize gestures, however if this view is used only to group its children it may get automatically collapsed.
* - Using the same instance of a gesture across multiple Gesture Detectors is not possible.
*
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector
*/
export const GestureDetector = props => {
const rootViewContext = useContext(GestureHandlerRootViewContext);
if (__DEV__ && !rootViewContext && !isJestEnv() && Platform.OS !== 'web') {
throw new Error('GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
}
const gestureConfig = props.gesture;
if (props.userSelect) {
applyUserSelectProp(props.userSelect, gestureConfig);
}
if (props.enableContextMenu !== undefined) {
applyEnableContextMenuProp(props.enableContextMenu, gestureConfig);
}
if (props.touchAction !== undefined) {
applyTouchActionProp(props.touchAction, gestureConfig);
}
const gesture = gestureConfig.toGestureArray();
const useReanimatedHook = gesture.some(g => g.shouldUseReanimated); // store state in ref to prevent unnecessary renders
const state = useRef({
firstRender: true,
viewRef: null,
previousViewTag: -1,
forceReattach: false
}).current;
const mountedRef = useRef(false);
const webEventHandlersRef = useRef({
onGestureHandlerEvent: e => {
onGestureHandlerEvent(e.nativeEvent);
},
onGestureHandlerStateChange: isNewWebImplementationEnabled() ? e => {
onGestureHandlerEvent(e.nativeEvent);
} : undefined
});
const [renderState, setRenderState] = useState(false);
function forceRender() {
setRenderState(!renderState);
}
const preparedGesture = React.useRef({
config: gesture,
animatedEventHandler: null,
animatedHandlers: null,
firstExecution: true,
useReanimatedHook: useReanimatedHook
}).current;
if (useReanimatedHook !== preparedGesture.useReanimatedHook) {
throw new Error(tagMessage('You cannot change the thread the callbacks are ran on while the app is running'));
}
function onHandlersUpdate(skipConfigUpdate) {
// if the underlying view has changed we need to reattach handlers to the new view
const viewTag = findNodeHandle(state.viewRef);
const forceReattach = viewTag !== state.previousViewTag;
if (forceReattach || needsToReattach(preparedGesture, gesture)) {
validateDetectorChildren(state.viewRef);
dropHandlers(preparedGesture);
attachHandlers({
preparedGesture,
gestureConfig,
gesture,
webEventHandlersRef,
viewTag,
mountedRef
});
state.previousViewTag = viewTag;
state.forceReattach = forceReattach;
if (forceReattach) {
forceRender();
}
} else if (!skipConfigUpdate) {
updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef);
}
} // Reanimated event should be rebuilt only when gestures are reattached, otherwise
// config update will be enough as all necessary items are stored in shared values anyway
const needsToRebuildReanimatedEvent = preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture) || state.forceReattach;
state.forceReattach = false;
if (preparedGesture.firstExecution) {
gestureConfig.initialize();
}
if (useReanimatedHook) {
// Whether animatedGesture or gesture is used shouldn't change while the app is running
// eslint-disable-next-line react-hooks/rules-of-hooks
useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
}
useEffect(() => {
const viewTag = findNodeHandle(state.viewRef);
state.firstRender = true;
mountedRef.current = true;
validateDetectorChildren(state.viewRef);
attachHandlers({
preparedGesture,
gestureConfig,
gesture,
webEventHandlersRef,
viewTag,
mountedRef
});
return () => {
mountedRef.current = false;
dropHandlers(preparedGesture);
};
}, []);
useEffect(() => {
if (!state.firstRender) {
onHandlersUpdate();
} else {
state.firstRender = false;
}
}, [props]);
const refFunction = ref => {
if (ref !== null) {
// @ts-ignore Just setting the view ref
state.viewRef = ref; // if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed
if (state.previousViewTag === -1) {
state.previousViewTag = findNodeHandle(state.viewRef);
} // pass true as `skipConfigUpdate`, here we only want to trigger the eventual reattaching of handlers
// in case the view has changed, while config update would be handled be the `useEffect` above
onHandlersUpdate(true);
if (isFabric() && global.isFormsStackingContext) {
const node = getShadowNodeFromRef(ref);
if (global.isFormsStackingContext(node) === false) {
console.error(tagMessage('GestureDetector has received a child that may get view-flattened. ' + '\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'));
}
}
}
};
if (useReanimatedHook) {
return /*#__PURE__*/React.createElement(AnimatedWrap, {
ref: refFunction,
onGestureHandlerEvent: preparedGesture.animatedEventHandler
}, props.children);
} else {
return /*#__PURE__*/React.createElement(Wrap, {
ref: refFunction
}, props.children);
}
};
class Wrap extends React.Component {
render() {
try {
// I don't think that fighting with types over such a simple function is worth it
// The only thing it does is add 'collapsable: false' to the child component
// to make sure it is in the native view hierarchy so the detector can find
// correct viewTag to attach to.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const child = React.Children.only(this.props.children);
return /*#__PURE__*/React.cloneElement(child, {
collapsable: false
}, // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
child.props.children);
} catch (e) {
throw new Error(tagMessage(`GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
}
}
}
const AnimatedWrap = (_Reanimated$default$c = Reanimated === null || Reanimated === void 0 ? void 0 : (_Reanimated$default = Reanimated.default) === null || _Reanimated$default === void 0 ? void 0 : _Reanimated$default.createAnimatedComponent(Wrap)) !== null && _Reanimated$default$c !== void 0 ? _Reanimated$default$c : Wrap;
//# sourceMappingURL=GestureDetector.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,131 @@
import { DeviceEventEmitter } from 'react-native';
import { State } from '../../State';
import { TouchEventType } from '../../TouchEventType';
import { findHandler, findOldGestureHandler } from '../handlersRegistry';
import { GestureStateManager } from './gestureStateManager';
let gestureHandlerEventSubscription = null;
let gestureHandlerStateChangeEventSubscription = null;
const gestureStateManagers = new Map();
const lastUpdateEvent = [];
function isStateChangeEvent(event) {
// @ts-ignore oldState doesn't exist on GestureTouchEvent and that's the point
return event.oldState != null;
}
function isTouchEvent(event) {
return event.eventType != null;
}
export function onGestureHandlerEvent(event) {
var _handler$handlers7, _handler$handlers7$on, _handler$handlers8, _handler$handlers8$on, _handler$handlers9, _handler$handlers9$on, _handler$handlers10, _handler$handlers10$o;
const handler = findHandler(event.handlerTag);
if (handler) {
if (isStateChangeEvent(event)) {
if (event.oldState === State.UNDETERMINED && event.state === State.BEGAN) {
var _handler$handlers$onB, _handler$handlers;
(_handler$handlers$onB = (_handler$handlers = handler.handlers).onBegin) === null || _handler$handlers$onB === void 0 ? void 0 : _handler$handlers$onB.call(_handler$handlers, event);
} else if ((event.oldState === State.BEGAN || event.oldState === State.UNDETERMINED) && event.state === State.ACTIVE) {
var _handler$handlers$onS, _handler$handlers2;
(_handler$handlers$onS = (_handler$handlers2 = handler.handlers).onStart) === null || _handler$handlers$onS === void 0 ? void 0 : _handler$handlers$onS.call(_handler$handlers2, event);
lastUpdateEvent[handler.handlers.handlerTag] = event;
} else if (event.oldState !== event.state && event.state === State.END) {
var _handler$handlers$onF, _handler$handlers4;
if (event.oldState === State.ACTIVE) {
var _handler$handlers$onE, _handler$handlers3;
(_handler$handlers$onE = (_handler$handlers3 = handler.handlers).onEnd) === null || _handler$handlers$onE === void 0 ? void 0 : _handler$handlers$onE.call(_handler$handlers3, event, true);
}
(_handler$handlers$onF = (_handler$handlers4 = handler.handlers).onFinalize) === null || _handler$handlers$onF === void 0 ? void 0 : _handler$handlers$onF.call(_handler$handlers4, event, true);
lastUpdateEvent[handler.handlers.handlerTag] = undefined;
} else if ((event.state === State.FAILED || event.state === State.CANCELLED) && event.oldState !== event.state) {
var _handler$handlers$onF2, _handler$handlers6;
if (event.oldState === State.ACTIVE) {
var _handler$handlers$onE2, _handler$handlers5;
(_handler$handlers$onE2 = (_handler$handlers5 = handler.handlers).onEnd) === null || _handler$handlers$onE2 === void 0 ? void 0 : _handler$handlers$onE2.call(_handler$handlers5, event, false);
}
(_handler$handlers$onF2 = (_handler$handlers6 = handler.handlers).onFinalize) === null || _handler$handlers$onF2 === void 0 ? void 0 : _handler$handlers$onF2.call(_handler$handlers6, event, false);
gestureStateManagers.delete(event.handlerTag);
lastUpdateEvent[handler.handlers.handlerTag] = undefined;
}
} else if (isTouchEvent(event)) {
if (!gestureStateManagers.has(event.handlerTag)) {
gestureStateManagers.set(event.handlerTag, GestureStateManager.create(event.handlerTag));
} // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const manager = gestureStateManagers.get(event.handlerTag);
switch (event.eventType) {
case TouchEventType.TOUCHES_DOWN:
(_handler$handlers7 = handler.handlers) === null || _handler$handlers7 === void 0 ? void 0 : (_handler$handlers7$on = _handler$handlers7.onTouchesDown) === null || _handler$handlers7$on === void 0 ? void 0 : _handler$handlers7$on.call(_handler$handlers7, event, manager);
break;
case TouchEventType.TOUCHES_MOVE:
(_handler$handlers8 = handler.handlers) === null || _handler$handlers8 === void 0 ? void 0 : (_handler$handlers8$on = _handler$handlers8.onTouchesMove) === null || _handler$handlers8$on === void 0 ? void 0 : _handler$handlers8$on.call(_handler$handlers8, event, manager);
break;
case TouchEventType.TOUCHES_UP:
(_handler$handlers9 = handler.handlers) === null || _handler$handlers9 === void 0 ? void 0 : (_handler$handlers9$on = _handler$handlers9.onTouchesUp) === null || _handler$handlers9$on === void 0 ? void 0 : _handler$handlers9$on.call(_handler$handlers9, event, manager);
break;
case TouchEventType.TOUCHES_CANCELLED:
(_handler$handlers10 = handler.handlers) === null || _handler$handlers10 === void 0 ? void 0 : (_handler$handlers10$o = _handler$handlers10.onTouchesCancelled) === null || _handler$handlers10$o === void 0 ? void 0 : _handler$handlers10$o.call(_handler$handlers10, event, manager);
break;
}
} else {
var _handler$handlers$onU, _handler$handlers11;
(_handler$handlers$onU = (_handler$handlers11 = handler.handlers).onUpdate) === null || _handler$handlers$onU === void 0 ? void 0 : _handler$handlers$onU.call(_handler$handlers11, event);
if (handler.handlers.onChange && handler.handlers.changeEventCalculator) {
var _handler$handlers$onC, _handler$handlers12, _handler$handlers$cha, _handler$handlers13;
(_handler$handlers$onC = (_handler$handlers12 = handler.handlers).onChange) === null || _handler$handlers$onC === void 0 ? void 0 : _handler$handlers$onC.call(_handler$handlers12, (_handler$handlers$cha = (_handler$handlers13 = handler.handlers).changeEventCalculator) === null || _handler$handlers$cha === void 0 ? void 0 : _handler$handlers$cha.call(_handler$handlers13, event, lastUpdateEvent[handler.handlers.handlerTag]));
lastUpdateEvent[handler.handlers.handlerTag] = event;
}
}
} else {
const oldHandler = findOldGestureHandler(event.handlerTag);
if (oldHandler) {
const nativeEvent = {
nativeEvent: event
};
if (isStateChangeEvent(event)) {
oldHandler.onGestureStateChange(nativeEvent);
} else {
oldHandler.onGestureEvent(nativeEvent);
}
return;
}
}
}
export function startListening() {
stopListening();
gestureHandlerEventSubscription = DeviceEventEmitter.addListener('onGestureHandlerEvent', onGestureHandlerEvent);
gestureHandlerStateChangeEventSubscription = DeviceEventEmitter.addListener('onGestureHandlerStateChange', onGestureHandlerEvent);
}
export function stopListening() {
if (gestureHandlerEventSubscription) {
gestureHandlerEventSubscription.remove();
gestureHandlerEventSubscription = null;
}
if (gestureHandlerStateChangeEventSubscription) {
gestureHandlerStateChangeEventSubscription.remove();
gestureHandlerStateChangeEventSubscription = null;
}
}
//# sourceMappingURL=eventReceiver.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture } from './gesture';
export class FlingGesture extends BaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'FlingGestureHandler';
}
/**
* Determine exact number of points required to handle the fling gesture.
* @param pointers
*/
numberOfPointers(pointers) {
this.config.numberOfPointers = pointers;
return this;
}
/**
* Expressed allowed direction of movement.
* Expected values are exported as constants in the Directions object.
* Arguments can be combined using `|` operator. Default value is set to `MouseButton.LEFT`.
* @param direction
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions
*/
direction(direction) {
this.config.direction = direction;
return this;
}
}
//# sourceMappingURL=flingGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["flingGesture.ts"],"names":["BaseGesture","FlingGesture","constructor","handlerName","numberOfPointers","pointers","config","direction"],"mappings":";;AAAA,SAASA,WAAT,QAA+C,WAA/C;AAMA,OAAO,MAAMC,YAAN,SAA2BD,WAA3B,CAAwE;AAG7EE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,gBAAgB,CAACC,QAAD,EAAmB;AACjC,SAAKC,MAAL,CAAYF,gBAAZ,GAA+BC,QAA/B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACEE,EAAAA,SAAS,CAACA,SAAD,EAAoB;AAC3B,SAAKD,MAAL,CAAYC,SAAZ,GAAwBA,SAAxB;AACA,WAAO,IAAP;AACD;;AA5B4E","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n FlingGestureConfig,\n FlingGestureHandlerEventPayload,\n} from '../FlingGestureHandler';\n\nexport class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {\n public config: BaseGestureConfig & FlingGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'FlingGestureHandler';\n }\n\n /**\n * Determine exact number of points required to handle the fling gesture.\n * @param pointers\n */\n numberOfPointers(pointers: number) {\n this.config.numberOfPointers = pointers;\n return this;\n }\n\n /**\n * Expressed allowed direction of movement.\n * Expected values are exported as constants in the Directions object.\n * Arguments can be combined using `|` operator. Default value is set to `MouseButton.LEFT`.\n * @param direction\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions\n */\n direction(direction: number) {\n this.config.direction = direction;\n return this;\n }\n}\n\nexport type FlingGestureType = InstanceType<typeof FlingGesture>;\n"]}

View File

@@ -0,0 +1,73 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
forceChange: current.force
};
} else {
changePayload = {
forceChange: current.force - previous.force
};
}
return { ...current,
...changePayload
};
}
export class ForceTouchGesture extends ContinousBaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'ForceTouchGestureHandler';
}
/**
* A minimal pressure that is required before gesture can activate.
* Should be a value from range [0.0, 1.0]. Default is 0.2.
* @param force
*/
minForce(force) {
this.config.minForce = force;
return this;
}
/**
* A maximal pressure that could be applied for gesture.
* If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].
* @param force
*/
maxForce(force) {
this.config.maxForce = force;
return this;
}
/**
* Value defining if haptic feedback has to be performed on activation.
* @param value
*/
feedbackOnActivation(value) {
this.config.feedbackOnActivation = value;
return this;
}
onChange(callback) {
// @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=forceTouchGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["forceTouchGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","forceChange","force","ForceTouchGesture","constructor","handlerName","minForce","config","maxForce","feedbackOnActivation","value","onChange","callback","handlers"],"mappings":";;AAAA,SAA4BA,oBAA5B,QAAwD,WAAxD;;AAWA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK;AADP,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK,KAAR,GAAgBJ,QAAQ,CAACI;AADxB,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMI,iBAAN,SAAgCR,oBAAhC,CAGL;AAGAS,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF+C,EAE/C;;AAGZ,SAAKC,WAAL,GAAmB,0BAAnB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,QAAQ,CAACJ,KAAD,EAAgB;AACtB,SAAKK,MAAL,CAAYD,QAAZ,GAAuBJ,KAAvB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEM,EAAAA,QAAQ,CAACN,KAAD,EAAgB;AACtB,SAAKK,MAAL,CAAYC,QAAZ,GAAuBN,KAAvB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;;;AACEO,EAAAA,oBAAoB,CAACC,KAAD,EAAiB;AACnC,SAAKH,MAAL,CAAYE,oBAAZ,GAAmCC,KAAnC;AACA,WAAO,IAAP;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EASN;AACA;AACA,SAAKC,QAAL,CAAcjB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMe,QAAN,CAAeC,QAAf,CAAP;AACD;;AAnDD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport {\n ForceTouchGestureConfig,\n ForceTouchGestureHandlerEventPayload,\n} from '../ForceTouchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type ForceTouchGestureChangeEventPayload = {\n forceChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: ForceTouchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n forceChange: current.force,\n };\n } else {\n changePayload = {\n forceChange: current.force - previous.force,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class ForceTouchGesture extends ContinousBaseGesture<\n ForceTouchGestureHandlerEventPayload,\n ForceTouchGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & ForceTouchGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'ForceTouchGestureHandler';\n }\n\n /**\n * A minimal pressure that is required before gesture can activate.\n * Should be a value from range [0.0, 1.0]. Default is 0.2.\n * @param force\n */\n minForce(force: number) {\n this.config.minForce = force;\n return this;\n }\n\n /**\n * A maximal pressure that could be applied for gesture.\n * If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].\n * @param force\n */\n maxForce(force: number) {\n this.config.maxForce = force;\n return this;\n }\n\n /**\n * Value defining if haptic feedback has to be performed on activation.\n * @param value\n */\n feedbackOnActivation(value: boolean) {\n this.config.feedbackOnActivation = value;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n GestureUpdateEvent<\n ForceTouchGestureHandlerEventPayload &\n ForceTouchGestureChangeEventPayload\n >\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;\n"]}

View File

@@ -0,0 +1,362 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { getNextHandlerTag } from '../handlersRegistry';
import { isRemoteDebuggingEnabled } from '../../utils';
export const CALLBACK_TYPE = {
UNDEFINED: 0,
BEGAN: 1,
START: 2,
UPDATE: 3,
CHANGE: 4,
END: 5,
FINALIZE: 6,
TOUCHES_DOWN: 7,
TOUCHES_MOVE: 8,
TOUCHES_UP: 9,
TOUCHES_CANCELLED: 10
}; // Allow using CALLBACK_TYPE as object and type
// eslint-disable-next-line @typescript-eslint/no-redeclare
export class Gesture {}
let nextGestureId = 0;
export class BaseGesture extends Gesture {
constructor() {
super(); // Used to check whether the gesture config has been updated when wrapping it
// with `useMemo`. Since every config will have a unique id, when the dependencies
// don't change, the config won't be recreated and the id will stay the same.
// If the id is different, it means that the config has changed and the gesture
// needs to be updated.
_defineProperty(this, "gestureId", -1);
_defineProperty(this, "handlerTag", -1);
_defineProperty(this, "handlerName", '');
_defineProperty(this, "config", {});
_defineProperty(this, "handlers", {
gestureId: -1,
handlerTag: -1,
isWorklet: []
});
this.gestureId = nextGestureId++;
this.handlers.gestureId = this.gestureId;
}
addDependency(key, gesture) {
const value = this.config[key];
this.config[key] = value ? Array().concat(value, gesture) : [gesture];
}
/**
* Sets a `ref` to the gesture object, allowing for interoperability with the old API.
* @param ref
*/
withRef(ref) {
this.config.ref = ref;
return this;
} // eslint-disable-next-line @typescript-eslint/ban-types
isWorklet(callback) {
//@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
return callback.__workletHash !== undefined;
}
/**
* Set the callback that is being called when given gesture handler starts receiving touches.
* At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.
* @param callback
*/
onBegin(callback) {
this.handlers.onBegin = callback;
this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);
return this;
}
/**
* Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.
* @param callback
*/
onStart(callback) {
this.handlers.onStart = callback;
this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);
return this;
}
/**
* Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.
* It will be called only if the handler was previously in the `ACTIVE` state.
* @param callback
*/
onEnd(callback) {
this.handlers.onEnd = callback; //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);
return this;
}
/**
* Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.
* @param callback
*/
onFinalize(callback) {
this.handlers.onFinalize = callback; //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);
return this;
}
/**
* Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.
* @param callback
*/
onTouchesDown(callback) {
this.config.needsPointerData = true;
this.handlers.onTouchesDown = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] = this.isWorklet(callback);
return this;
}
/**
* Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.
* @param callback
*/
onTouchesMove(callback) {
this.config.needsPointerData = true;
this.handlers.onTouchesMove = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] = this.isWorklet(callback);
return this;
}
/**
* Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.
* @param callback
*/
onTouchesUp(callback) {
this.config.needsPointerData = true;
this.handlers.onTouchesUp = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] = this.isWorklet(callback);
return this;
}
/**
* Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.
* @param callback
*/
onTouchesCancelled(callback) {
this.config.needsPointerData = true;
this.handlers.onTouchesCancelled = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] = this.isWorklet(callback);
return this;
}
/**
* Indicates whether the given handler should be analyzing stream of touch events or not.
* @param enabled
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean
*/
enabled(enabled) {
this.config.enabled = enabled;
return this;
}
/**
* When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.
* @param value
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean
*/
shouldCancelWhenOutside(value) {
this.config.shouldCancelWhenOutside = value;
return this;
}
/**
* This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.
* When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.
* @param hitSlop
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings
*/
hitSlop(hitSlop) {
this.config.hitSlop = hitSlop;
return this;
}
/**
* #### Web only
* This parameter allows to specify which `cursor` should be used when gesture activates.
* Supports all CSS cursor values (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`.
* @param activeCursor
*/
activeCursor(activeCursor) {
this.config.activeCursor = activeCursor;
return this;
}
/**
* #### Web & Android only
* Allows users to choose which mouse button should handler respond to.
* Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.
* Default value is set to `MouseButton.LEFT`.
* @param mouseButton
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only
*/
mouseButton(mouseButton) {
this.config.mouseButton = mouseButton;
return this;
}
/**
* When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.
* This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.
* Defaults to `false`.
* @param runOnJS
*/
runOnJS(runOnJS) {
this.config.runOnJS = runOnJS;
return this;
}
/**
* Allows gestures across different components to be recognized simultaneously.
* @param gestures
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture
*/
simultaneousWithExternalGesture(...gestures) {
for (const gesture of gestures) {
this.addDependency('simultaneousWith', gesture);
}
return this;
}
/**
* Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).
* @param gestures
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail
*/
requireExternalGestureToFail(...gestures) {
for (const gesture of gestures) {
this.addDependency('requireToFail', gesture);
}
return this;
}
/**
* Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.
* @param gestures
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture
*/
blocksExternalGesture(...gestures) {
for (const gesture of gestures) {
this.addDependency('blocksHandlers', gesture);
}
return this;
}
/**
* Sets a `testID` property for gesture object, allowing for querying for it in tests.
* @param id
*/
withTestId(id) {
this.config.testId = id;
return this;
}
/**
* #### iOS only
* When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.
* Default value is `true`.
* @param value
*/
cancelsTouchesInView(value) {
this.config.cancelsTouchesInView = value;
return this;
}
initialize() {
this.handlerTag = getNextHandlerTag();
this.handlers = { ...this.handlers,
handlerTag: this.handlerTag
};
if (this.config.ref) {
this.config.ref.current = this;
}
}
toGestureArray() {
return [this];
} // eslint-disable-next-line @typescript-eslint/no-empty-function
prepare() {}
get shouldUseReanimated() {
// use Reanimated when runOnJS isn't set explicitly,
// and all defined callbacks are worklets,
// and remote debugging is disabled
return this.config.runOnJS !== true && !this.handlers.isWorklet.includes(false) && !isRemoteDebuggingEnabled();
}
}
export class ContinousBaseGesture extends BaseGesture {
/**
* Set the callback that is being called every time the gesture receives an update while it's active.
* @param callback
*/
onUpdate(callback) {
this.handlers.onUpdate = callback;
this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);
return this;
}
/**
* Set the callback that is being called every time the gesture receives an update while it's active.
* This callback will receive information about change in value in relation to the last received event.
* @param callback
*/
onChange(callback) {
this.handlers.onChange = callback;
this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);
return this;
}
/**
* When `true` the handler will not activate by itself even if its activation criteria are met.
* Instead you can manipulate its state using state manager.
* @param manualActivation
*/
manualActivation(manualActivation) {
this.config.manualActivation = manualActivation;
return this;
}
}
//# sourceMappingURL=gesture.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,90 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture, Gesture } from './gesture';
function extendRelation(currentRelation, extendWith) {
if (currentRelation === undefined) {
return [...extendWith];
} else {
return [...currentRelation, ...extendWith];
}
}
export class ComposedGesture extends Gesture {
constructor(...gestures) {
super();
_defineProperty(this, "gestures", []);
_defineProperty(this, "simultaneousGestures", []);
_defineProperty(this, "requireGesturesToFail", []);
this.gestures = gestures;
}
prepareSingleGesture(gesture, simultaneousGestures, requireGesturesToFail) {
if (gesture instanceof BaseGesture) {
const newConfig = { ...gesture.config
};
newConfig.simultaneousWith = extendRelation(newConfig.simultaneousWith, simultaneousGestures);
newConfig.requireToFail = extendRelation(newConfig.requireToFail, requireGesturesToFail);
gesture.config = newConfig;
} else if (gesture instanceof ComposedGesture) {
gesture.simultaneousGestures = simultaneousGestures;
gesture.requireGesturesToFail = requireGesturesToFail;
gesture.prepare();
}
}
prepare() {
for (const gesture of this.gestures) {
this.prepareSingleGesture(gesture, this.simultaneousGestures, this.requireGesturesToFail);
}
}
initialize() {
for (const gesture of this.gestures) {
gesture.initialize();
}
}
toGestureArray() {
return this.gestures.flatMap(gesture => gesture.toGestureArray());
}
}
export class SimultaneousGesture extends ComposedGesture {
prepare() {
// this piece of magic works something like this:
// for every gesture in the array
const simultaneousArrays = this.gestures.map(gesture => // we take the array it's in
this.gestures // and make a copy without it
.filter(x => x !== gesture) // then we flatmap the result to get list of raw (not composed) gestures
// this way we don't make the gestures simultaneous with themselves, which is
// important when the gesture is `ExclusiveGesture` - we don't want to make
// exclusive gestures simultaneous
.flatMap(x => x.toGestureArray()));
for (let i = 0; i < this.gestures.length; i++) {
this.prepareSingleGesture(this.gestures[i], simultaneousArrays[i], this.requireGesturesToFail);
}
}
}
export class ExclusiveGesture extends ComposedGesture {
prepare() {
// transforms the array of gestures into array of grouped raw (not composed) gestures
// i.e. [gesture1, gesture2, ComposedGesture(gesture3, gesture4)] -> [[gesture1], [gesture2], [gesture3, gesture4]]
const gestureArrays = this.gestures.map(gesture => gesture.toGestureArray());
let requireToFail = [];
for (let i = 0; i < this.gestures.length; i++) {
this.prepareSingleGesture(this.gestures[i], this.simultaneousGestures, this.requireGesturesToFail.concat(requireToFail)); // every group gets to wait for all groups before it
requireToFail = requireToFail.concat(gestureArrays[i]);
}
}
}
//# sourceMappingURL=gestureComposition.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,138 @@
import { FlingGesture } from './flingGesture';
import { ForceTouchGesture } from './forceTouchGesture';
import { ComposedGesture, ExclusiveGesture, SimultaneousGesture } from './gestureComposition';
import { LongPressGesture } from './longPressGesture';
import { PanGesture } from './panGesture';
import { PinchGesture } from './pinchGesture';
import { RotationGesture } from './rotationGesture';
import { TapGesture } from './tapGesture';
import { NativeGesture } from './nativeGesture';
import { ManualGesture } from './manualGesture';
import { HoverGesture } from './hoverGesture';
/**
* `Gesture` is the object that allows you to create and compose gestures.
*
* ### Remarks
* - Consider wrapping your gesture configurations with `useMemo`, as it will reduce the amount of work Gesture Handler has to do under the hood when updating gestures.
*
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture
*/
export const GestureObjects = {
/**
* A discrete gesture that recognizes one or many taps.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture
*/
Tap: () => {
return new TapGesture();
},
/**
* A continuous gesture that can recognize a panning (dragging) gesture and track its movement.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture
*/
Pan: () => {
return new PanGesture();
},
/**
* A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or zoom your content.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pinch-gesture
*/
Pinch: () => {
return new PinchGesture();
},
/**
* A continuous gesture that can recognize rotation and track its movement.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/rotation-gesture
*/
Rotation: () => {
return new RotationGesture();
},
/**
* A discrete gesture that activates when the movement is sufficiently fast.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture
*/
Fling: () => {
return new FlingGesture();
},
/**
* A discrete gesture that activates when the corresponding view is pressed for a sufficiently long time.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture
*/
LongPress: () => {
return new LongPressGesture();
},
/**
* #### iOS only
* A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/force-touch-gesture
*/
ForceTouch: () => {
return new ForceTouchGesture();
},
/**
* A gesture that allows other touch handling components to participate in RNGH's gesture system.
* When used, the other component should be the direct child of a `GestureDetector`.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/native-gesture
*/
Native: () => {
return new NativeGesture();
},
/**
* A plain gesture that has no specific activation criteria nor event data set.
* Its state has to be controlled manually using a state manager.
* It will not fail when all the pointers are lifted from the screen.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/manual-gesture
*/
Manual: () => {
return new ManualGesture();
},
/**
* A continuous gesture that can recognize hovering above the view it's attached to.
* The hover effect may be activated by moving a mouse or a stylus over the view.
*
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/hover-gesture
*/
Hover: () => {
return new HoverGesture();
},
/**
* Builds a composed gesture consisting of gestures provided as parameters.
* The first one that becomes active cancels the rest of gestures.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#race
*/
Race: (...gestures) => {
return new ComposedGesture(...gestures);
},
/**
* Builds a composed gesture that allows all base gestures to run simultaneously.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneous
*/
Simultaneous(...gestures) {
return new SimultaneousGesture(...gestures);
},
/**
* Builds a composed gesture where only one of the provided gestures can become active.
* Priority is decided through the order of gestures: the first one has higher priority
* than the second one, second one has higher priority than the third one, and so on.
* For example, to make a gesture that recognizes both single and double tap you need
* to call Exclusive(doubleTap, singleTap).
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#exclusive
*/
Exclusive(...gestures) {
return new ExclusiveGesture(...gestures);
}
};
//# sourceMappingURL=gestureObjects.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,56 @@
import { Reanimated } from './reanimatedWrapper';
import { State } from '../../State';
import { tagMessage } from '../../utils';
const warningMessage = tagMessage('react-native-reanimated is required in order to use synchronous state management'); // check if reanimated module is available, but look for useSharedValue as conditional
// require of reanimated can sometimes return content of `utils.ts` file (?)
const REANIMATED_AVAILABLE = (Reanimated === null || Reanimated === void 0 ? void 0 : Reanimated.useSharedValue) !== undefined;
const setGestureState = Reanimated === null || Reanimated === void 0 ? void 0 : Reanimated.setGestureState;
function create(handlerTag) {
'worklet';
return {
begin: () => {
'worklet';
if (REANIMATED_AVAILABLE) {
setGestureState(handlerTag, State.BEGAN);
} else {
console.warn(warningMessage);
}
},
activate: () => {
'worklet';
if (REANIMATED_AVAILABLE) {
setGestureState(handlerTag, State.ACTIVE);
} else {
console.warn(warningMessage);
}
},
fail: () => {
'worklet';
if (REANIMATED_AVAILABLE) {
setGestureState(handlerTag, State.FAILED);
} else {
console.warn(warningMessage);
}
},
end: () => {
'worklet';
if (REANIMATED_AVAILABLE) {
setGestureState(handlerTag, State.END);
} else {
console.warn(warningMessage);
}
}
};
}
export const GestureStateManager = {
create
};
//# sourceMappingURL=gestureStateManager.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["gestureStateManager.ts"],"names":["Reanimated","State","tagMessage","warningMessage","REANIMATED_AVAILABLE","useSharedValue","undefined","setGestureState","create","handlerTag","begin","BEGAN","console","warn","activate","ACTIVE","fail","FAILED","end","END","GestureStateManager"],"mappings":"AAAA,SAASA,UAAT,QAA2B,qBAA3B;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,UAAT,QAA2B,aAA3B;AASA,MAAMC,cAAc,GAAGD,UAAU,CAC/B,kFAD+B,CAAjC,C,CAIA;AACA;;AACA,MAAME,oBAAoB,GAAG,CAAAJ,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEK,cAAZ,MAA+BC,SAA5D;AACA,MAAMC,eAAe,GAAGP,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEO,eAApC;;AAEA,SAASC,MAAT,CAAgBC,UAAhB,EAA6D;AAC3D;;AACA,SAAO;AACLC,IAAAA,KAAK,EAAE,MAAM;AACX;;AACA,UAAIN,oBAAJ,EAA0B;AACxBG,QAAAA,eAAe,CAACE,UAAD,EAAaR,KAAK,CAACU,KAAnB,CAAf;AACD,OAFD,MAEO;AACLC,QAAAA,OAAO,CAACC,IAAR,CAAaV,cAAb;AACD;AACF,KARI;AAULW,IAAAA,QAAQ,EAAE,MAAM;AACd;;AACA,UAAIV,oBAAJ,EAA0B;AACxBG,QAAAA,eAAe,CAACE,UAAD,EAAaR,KAAK,CAACc,MAAnB,CAAf;AACD,OAFD,MAEO;AACLH,QAAAA,OAAO,CAACC,IAAR,CAAaV,cAAb;AACD;AACF,KAjBI;AAmBLa,IAAAA,IAAI,EAAE,MAAM;AACV;;AACA,UAAIZ,oBAAJ,EAA0B;AACxBG,QAAAA,eAAe,CAACE,UAAD,EAAaR,KAAK,CAACgB,MAAnB,CAAf;AACD,OAFD,MAEO;AACLL,QAAAA,OAAO,CAACC,IAAR,CAAaV,cAAb;AACD;AACF,KA1BI;AA4BLe,IAAAA,GAAG,EAAE,MAAM;AACT;;AACA,UAAId,oBAAJ,EAA0B;AACxBG,QAAAA,eAAe,CAACE,UAAD,EAAaR,KAAK,CAACkB,GAAnB,CAAf;AACD,OAFD,MAEO;AACLP,QAAAA,OAAO,CAACC,IAAR,CAAaV,cAAb;AACD;AACF;AAnCI,GAAP;AAqCD;;AAED,OAAO,MAAMiB,mBAAmB,GAAG;AACjCZ,EAAAA;AADiC,CAA5B","sourcesContent":["import { Reanimated } from './reanimatedWrapper';\nimport { State } from '../../State';\nimport { tagMessage } from '../../utils';\n\nexport interface GestureStateManagerType {\n begin: () => void;\n activate: () => void;\n fail: () => void;\n end: () => void;\n}\n\nconst warningMessage = tagMessage(\n 'react-native-reanimated is required in order to use synchronous state management'\n);\n\n// check if reanimated module is available, but look for useSharedValue as conditional\n// require of reanimated can sometimes return content of `utils.ts` file (?)\nconst REANIMATED_AVAILABLE = Reanimated?.useSharedValue !== undefined;\nconst setGestureState = Reanimated?.setGestureState;\n\nfunction create(handlerTag: number): GestureStateManagerType {\n 'worklet';\n return {\n begin: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.BEGAN);\n } else {\n console.warn(warningMessage);\n }\n },\n\n activate: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.ACTIVE);\n } else {\n console.warn(warningMessage);\n }\n },\n\n fail: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.FAILED);\n } else {\n console.warn(warningMessage);\n }\n },\n\n end: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.END);\n } else {\n console.warn(warningMessage);\n }\n },\n };\n}\n\nexport const GestureStateManager = {\n create,\n};\n"]}

View File

@@ -0,0 +1,21 @@
import NodeManager from '../../web/tools/NodeManager';
export const GestureStateManager = {
create(handlerTag) {
return {
begin: () => {
NodeManager.getHandler(handlerTag).begin();
},
activate: () => {
NodeManager.getHandler(handlerTag).activate(true);
},
fail: () => {
NodeManager.getHandler(handlerTag).fail();
},
end: () => {
NodeManager.getHandler(handlerTag).end();
}
};
}
};
//# sourceMappingURL=gestureStateManager.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["gestureStateManager.web.ts"],"names":["NodeManager","GestureStateManager","create","handlerTag","begin","getHandler","activate","fail","end"],"mappings":"AAAA,OAAOA,WAAP,MAAwB,6BAAxB;AAGA,OAAO,MAAMC,mBAAmB,GAAG;AACjCC,EAAAA,MAAM,CAACC,UAAD,EAA8C;AAClD,WAAO;AACLC,MAAAA,KAAK,EAAE,MAAM;AACXJ,QAAAA,WAAW,CAACK,UAAZ,CAAuBF,UAAvB,EAAmCC,KAAnC;AACD,OAHI;AAKLE,MAAAA,QAAQ,EAAE,MAAM;AACdN,QAAAA,WAAW,CAACK,UAAZ,CAAuBF,UAAvB,EAAmCG,QAAnC,CAA4C,IAA5C;AACD,OAPI;AASLC,MAAAA,IAAI,EAAE,MAAM;AACVP,QAAAA,WAAW,CAACK,UAAZ,CAAuBF,UAAvB,EAAmCI,IAAnC;AACD,OAXI;AAaLC,MAAAA,GAAG,EAAE,MAAM;AACTR,QAAAA,WAAW,CAACK,UAAZ,CAAuBF,UAAvB,EAAmCK,GAAnC;AACD;AAfI,KAAP;AAiBD;;AAnBgC,CAA5B","sourcesContent":["import NodeManager from '../../web/tools/NodeManager';\nimport { GestureStateManagerType } from './gestureStateManager';\n\nexport const GestureStateManager = {\n create(handlerTag: number): GestureStateManagerType {\n return {\n begin: () => {\n NodeManager.getHandler(handlerTag).begin();\n },\n\n activate: () => {\n NodeManager.getHandler(handlerTag).activate(true);\n },\n\n fail: () => {\n NodeManager.getHandler(handlerTag).fail();\n },\n\n end: () => {\n NodeManager.getHandler(handlerTag).end();\n },\n };\n },\n};\n"]}

View File

@@ -0,0 +1,62 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { ContinousBaseGesture } from './gesture';
export let HoverEffect;
(function (HoverEffect) {
HoverEffect[HoverEffect["NONE"] = 0] = "NONE";
HoverEffect[HoverEffect["LIFT"] = 1] = "LIFT";
HoverEffect[HoverEffect["HIGHLIGHT"] = 2] = "HIGHLIGHT";
})(HoverEffect || (HoverEffect = {}));
export const hoverGestureHandlerProps = ['hoverEffect'];
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
changeX: current.x,
changeY: current.y
};
} else {
changePayload = {
changeX: current.x - previous.x,
changeY: current.y - previous.y
};
}
return { ...current,
...changePayload
};
}
export class HoverGesture extends ContinousBaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'HoverGestureHandler';
}
/**
* #### iOS only
* Sets the visual hover effect.
*/
effect(effect) {
this.config.hoverEffect = effect;
return this;
}
onChange(callback) {
// @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=hoverGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["hoverGesture.ts"],"names":["ContinousBaseGesture","HoverEffect","hoverGestureHandlerProps","changeEventCalculator","current","previous","changePayload","undefined","changeX","x","changeY","y","HoverGesture","constructor","handlerName","effect","config","hoverEffect","onChange","callback","handlers"],"mappings":";;AAAA,SAA4BA,oBAA5B,QAAwD,WAAxD;AAeA,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W;;AAUZ,OAAO,MAAMC,wBAAwB,GAAG,CAAC,aAAD,CAAjC;;AAEP,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CADH;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO;AAFH,KAAhB;AAID,GALD,MAKO;AACLL,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CAAR,GAAYJ,QAAQ,CAACI,CADhB;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO,CAAR,GAAYN,QAAQ,CAACM;AAFhB,KAAhB;AAID;;AAED,SAAO,EAAE,GAAGP,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMM,YAAN,SAA2BZ,oBAA3B,CAGL;AAGAa,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,MAAM,CAACA,MAAD,EAAsB;AAC1B,SAAKC,MAAL,CAAYC,WAAZ,GAA0BF,MAA1B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcjB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMe,QAAN,CAAeC,QAAf,CAAP;AACD;;AA5BD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type HoverGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type HoverGestureChangeEventPayload = {\n changeX: number;\n changeY: number;\n};\n\nexport enum HoverEffect {\n NONE = 0,\n LIFT = 1,\n HIGHLIGHT = 2,\n}\n\nexport interface HoverGestureConfig {\n hoverEffect?: HoverEffect;\n}\n\nexport const hoverGestureHandlerProps = ['hoverEffect'] as const;\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<HoverGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<HoverGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: HoverGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n changeX: current.x,\n changeY: current.y,\n };\n } else {\n changePayload = {\n changeX: current.x - previous.x,\n changeY: current.y - previous.y,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class HoverGesture extends ContinousBaseGesture<\n HoverGestureHandlerEventPayload,\n HoverGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & HoverGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'HoverGestureHandler';\n }\n\n /**\n * #### iOS only\n * Sets the visual hover effect.\n */\n effect(effect: HoverEffect) {\n this.config.hoverEffect = effect;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n HoverGestureHandlerEventPayload & HoverGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type HoverGestureType = InstanceType<typeof HoverGesture>;\n"]}

View File

@@ -0,0 +1,37 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture } from './gesture';
export class LongPressGesture extends BaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'LongPressGestureHandler';
this.shouldCancelWhenOutside(true);
}
/**
* Minimum time, expressed in milliseconds, that a finger must remain pressed on the corresponding view.
* The default value is 500.
* @param duration
*/
minDuration(duration) {
this.config.minDurationMs = duration;
return this;
}
/**
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a long press gesture.
* @param distance
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture#maxdistancevalue-number
*/
maxDistance(distance) {
this.config.maxDist = distance;
return this;
}
}
//# sourceMappingURL=longPressGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["longPressGesture.ts"],"names":["BaseGesture","LongPressGesture","constructor","handlerName","shouldCancelWhenOutside","minDuration","duration","config","minDurationMs","maxDistance","distance","maxDist"],"mappings":";;AAAA,SAASA,WAAT,QAA+C,WAA/C;AAMA,OAAO,MAAMC,gBAAN,SAA+BD,WAA/B,CAAgF;AAGrFE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF8C,EAE9C;;AAGZ,SAAKC,WAAL,GAAmB,yBAAnB;AACA,SAAKC,uBAAL,CAA6B,IAA7B;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKC,MAAL,CAAYC,aAAZ,GAA4BF,QAA5B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEG,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKH,MAAL,CAAYI,OAAZ,GAAsBD,QAAtB;AACA,WAAO,IAAP;AACD;;AA5BoF","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n LongPressGestureConfig,\n LongPressGestureHandlerEventPayload,\n} from '../LongPressGestureHandler';\n\nexport class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPayload> {\n public config: BaseGestureConfig & LongPressGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'LongPressGestureHandler';\n this.shouldCancelWhenOutside(true);\n }\n\n /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on the corresponding view.\n * The default value is 500.\n * @param duration\n */\n minDuration(duration: number) {\n this.config.minDurationMs = duration;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a long press gesture.\n * @param distance\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture#maxdistancevalue-number\n */\n maxDistance(distance: number) {\n this.config.maxDist = distance;\n return this;\n }\n}\n\nexport type LongPressGestureType = InstanceType<typeof LongPressGesture>;\n"]}

View File

@@ -0,0 +1,22 @@
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, _previous) {
'worklet';
return current;
}
export class ManualGesture extends ContinousBaseGesture {
constructor() {
super();
this.handlerName = 'ManualGestureHandler';
}
onChange(callback) {
// @ts-ignore TS being overprotective, Record<string, never> is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=manualGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["manualGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","_previous","ManualGesture","constructor","handlerName","onChange","callback","handlers"],"mappings":"AACA,SAASA,oBAAT,QAAqC,WAArC;;AAEA,SAASC,qBAAT,CACEC,OADF,EAEEC,SAFF,EAGE;AACA;;AACA,SAAOD,OAAP;AACD;;AAED,OAAO,MAAME,aAAN,SAA4BJ,oBAA5B,CAGL;AACAK,EAAAA,WAAW,GAAG;AACZ;AAEA,SAAKC,WAAL,GAAmB,sBAAnB;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAEN;AACA;AACA,SAAKC,QAAL,CAAcR,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMM,QAAN,CAAeC,QAAf,CAAP;AACD;;AAbD","sourcesContent":["import { GestureUpdateEvent } from '../gestureHandlerCommon';\nimport { ContinousBaseGesture } from './gesture';\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<Record<string, never>>,\n _previous?: GestureUpdateEvent<Record<string, never>>\n) {\n 'worklet';\n return current;\n}\n\nexport class ManualGesture extends ContinousBaseGesture<\n Record<string, never>,\n Record<string, never>\n> {\n constructor() {\n super();\n\n this.handlerName = 'ManualGestureHandler';\n }\n\n onChange(\n callback: (event: GestureUpdateEvent<Record<string, never>>) => void\n ) {\n // @ts-ignore TS being overprotective, Record<string, never> is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type ManualGestureType = InstanceType<typeof ManualGesture>;\n"]}

View File

@@ -0,0 +1,34 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture } from './gesture';
export class NativeGesture extends BaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'NativeViewGestureHandler';
}
/**
* When true, underlying handler will activate unconditionally when in `BEGAN` or `UNDETERMINED` state.
* @param value
*/
shouldActivateOnStart(value) {
this.config.shouldActivateOnStart = value;
return this;
}
/**
* When true, cancels all other gesture handlers when this `NativeViewGestureHandler` receives an `ACTIVE` state event.
* @param value
*/
disallowInterruption(value) {
this.config.disallowInterruption = value;
return this;
}
}
//# sourceMappingURL=nativeGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["nativeGesture.ts"],"names":["BaseGesture","NativeGesture","constructor","handlerName","shouldActivateOnStart","value","config","disallowInterruption"],"mappings":";;AAAA,SAA4BA,WAA5B,QAA+C,WAA/C;AAMA,OAAO,MAAMC,aAAN,SAA4BD,WAA5B,CAAyE;AAG9EE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF+C,EAE/C;;AAGZ,SAAKC,WAAL,GAAmB,0BAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,qBAAqB,CAACC,KAAD,EAAiB;AACpC,SAAKC,MAAL,CAAYF,qBAAZ,GAAoCC,KAApC;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;;;AACEE,EAAAA,oBAAoB,CAACF,KAAD,EAAiB;AACnC,SAAKC,MAAL,CAAYC,oBAAZ,GAAmCF,KAAnC;AACA,WAAO,IAAP;AACD;;AAzB6E","sourcesContent":["import { BaseGestureConfig, BaseGesture } from './gesture';\nimport {\n NativeViewGestureConfig,\n NativeViewGestureHandlerPayload,\n} from '../NativeViewGestureHandler';\n\nexport class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload> {\n public config: BaseGestureConfig & NativeViewGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'NativeViewGestureHandler';\n }\n\n /**\n * When true, underlying handler will activate unconditionally when in `BEGAN` or `UNDETERMINED` state.\n * @param value\n */\n shouldActivateOnStart(value: boolean) {\n this.config.shouldActivateOnStart = value;\n return this;\n }\n\n /**\n * When true, cancels all other gesture handlers when this `NativeViewGestureHandler` receives an `ACTIVE` state event.\n * @param value\n */\n disallowInterruption(value: boolean) {\n this.config.disallowInterruption = value;\n return this;\n }\n}\n\nexport type NativeGestureType = InstanceType<typeof NativeGesture>;\n"]}

View File

@@ -0,0 +1,216 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
changeX: current.translationX,
changeY: current.translationY
};
} else {
changePayload = {
changeX: current.translationX - previous.translationX,
changeY: current.translationY - previous.translationY
};
}
return { ...current,
...changePayload
};
}
export class PanGesture extends ContinousBaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'PanGestureHandler';
}
/**
* Range along Y axis (in points) where fingers travels without activation of gesture.
* @param offset
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#activeoffsetyvalue-number--number
*/
activeOffsetY(offset) {
if (Array.isArray(offset)) {
this.config.activeOffsetYStart = offset[0];
this.config.activeOffsetYEnd = offset[1];
} else if (offset < 0) {
this.config.activeOffsetYStart = offset;
} else {
this.config.activeOffsetYEnd = offset;
}
return this;
}
/**
* Range along X axis (in points) where fingers travels without activation of gesture.
* @param offset
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#activeoffsetxvalue-number--number
*/
activeOffsetX(offset) {
if (Array.isArray(offset)) {
this.config.activeOffsetXStart = offset[0];
this.config.activeOffsetXEnd = offset[1];
} else if (offset < 0) {
this.config.activeOffsetXStart = offset;
} else {
this.config.activeOffsetXEnd = offset;
}
return this;
}
/**
* When the finger moves outside this range (in points) along Y axis and gesture hasn't yet activated it will fail recognizing the gesture.
* @param offset
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#failoffsetyvalue-number--number
*/
failOffsetY(offset) {
if (Array.isArray(offset)) {
this.config.failOffsetYStart = offset[0];
this.config.failOffsetYEnd = offset[1];
} else if (offset < 0) {
this.config.failOffsetYStart = offset;
} else {
this.config.failOffsetYEnd = offset;
}
return this;
}
/**
* When the finger moves outside this range (in points) along X axis and gesture hasn't yet activated it will fail recognizing the gesture.
* @param offset
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#failoffsetxvalue-number--number
*/
failOffsetX(offset) {
if (Array.isArray(offset)) {
this.config.failOffsetXStart = offset[0];
this.config.failOffsetXEnd = offset[1];
} else if (offset < 0) {
this.config.failOffsetXStart = offset;
} else {
this.config.failOffsetXEnd = offset;
}
return this;
}
/**
* A number of fingers that is required to be placed before gesture can activate. Should be a higher or equal to 0 integer.
* @param minPointers
*/
minPointers(minPointers) {
this.config.minPointers = minPointers;
return this;
}
/**
* When the given number of fingers is placed on the screen and gesture hasn't yet activated it will fail recognizing the gesture.
* Should be a higher or equal to 0 integer.
* @param maxPointers
*/
maxPointers(maxPointers) {
this.config.maxPointers = maxPointers;
return this;
}
/**
* Minimum distance the finger (or multiple finger) need to travel before the gesture activates.
* Expressed in points.
* @param distance
*/
minDistance(distance) {
this.config.minDist = distance;
return this;
}
/**
* Minimum velocity the finger has to reach in order to activate handler.
* @param velocity
*/
minVelocity(velocity) {
this.config.minVelocity = velocity;
return this;
}
/**
* Minimum velocity along X axis the finger has to reach in order to activate handler.
* @param velocity
*/
minVelocityX(velocity) {
this.config.minVelocityX = velocity;
return this;
}
/**
* Minimum velocity along Y axis the finger has to reach in order to activate handler.
* @param velocity
*/
minVelocityY(velocity) {
this.config.minVelocityY = velocity;
return this;
}
/**
* #### Android only
* Android, by default, will calculate translation values based on the position of the leading pointer (the first one that was placed on the screen).
* This modifier allows that behavior to be changed to the one that is default on iOS - the averaged position of all active pointers will be used to calculate the translation values.
* @param value
*/
averageTouches(value) {
this.config.avgTouches = value;
return this;
}
/**
* #### iOS only
* Enables two-finger gestures on supported devices, for example iPads with trackpads.
* @param value
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture/#enabletrackpadtwofingergesturevalue-boolean-ios-only
*/
enableTrackpadTwoFingerGesture(value) {
this.config.enableTrackpadTwoFingerGesture = value;
return this;
}
/**
* Duration in milliseconds of the LongPress gesture before Pan is allowed to activate.
* @param duration
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture/#activateafterlongpressduration-number
*/
activateAfterLongPress(duration) {
this.config.activateAfterLongPress = duration;
return this;
}
onChange(callback) {
// @ts-ignore TS being overprotective, PanGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=panGesture.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,36 @@
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
scaleChange: current.scale
};
} else {
changePayload = {
scaleChange: current.scale / previous.scale
};
}
return { ...current,
...changePayload
};
}
export class PinchGesture extends ContinousBaseGesture {
constructor() {
super();
this.handlerName = 'PinchGestureHandler';
}
onChange(callback) {
// @ts-ignore TS being overprotective, PinchGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=pinchGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["pinchGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","scaleChange","scale","PinchGesture","constructor","handlerName","onChange","callback","handlers"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,WAArC;;AAQA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK;AADP,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK,KAAR,GAAgBJ,QAAQ,CAACI;AADxB,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMI,YAAN,SAA2BR,oBAA3B,CAGL;AACAS,EAAAA,WAAW,GAAG;AACZ;AAEA,SAAKC,WAAL,GAAmB,qBAAnB;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcZ,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMU,QAAN,CAAeC,QAAf,CAAP;AACD;;AAjBD","sourcesContent":["import { ContinousBaseGesture } from './gesture';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type PinchGestureChangeEventPayload = {\n scaleChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<PinchGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<PinchGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: PinchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n scaleChange: current.scale,\n };\n } else {\n changePayload = {\n scaleChange: current.scale / previous.scale,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class PinchGesture extends ContinousBaseGesture<\n PinchGestureHandlerEventPayload,\n PinchGestureChangeEventPayload\n> {\n constructor() {\n super();\n\n this.handlerName = 'PinchGestureHandler';\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n PinchGestureHandlerEventPayload & PinchGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, PinchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type PinchGestureType = InstanceType<typeof PinchGesture>;\n"]}

View File

@@ -0,0 +1,30 @@
var _Reanimated;
import { tagMessage } from '../../utils';
let Reanimated;
try {
Reanimated = require('react-native-reanimated');
} catch (e) {
// When 'react-native-reanimated' is not available we want to quietly continue
// @ts-ignore TS demands the variable to be initialized
Reanimated = undefined;
}
if (!((_Reanimated = Reanimated) !== null && _Reanimated !== void 0 && _Reanimated.useSharedValue)) {
// @ts-ignore Make sure the loaded module is actually Reanimated, if it's not
// reset the module to undefined so we can fallback to the default implementation
Reanimated = undefined;
}
if (Reanimated !== undefined && !Reanimated.setGestureState) {
// The loaded module is Reanimated but it doesn't have the setGestureState defined
Reanimated.setGestureState = () => {
'worklet';
console.warn(tagMessage('Please use newer version of react-native-reanimated in order to control state of the gestures.'));
};
}
export { Reanimated };
//# sourceMappingURL=reanimatedWrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["reanimatedWrapper.ts"],"names":["tagMessage","Reanimated","require","e","undefined","useSharedValue","setGestureState","console","warn"],"mappings":";;AAKA,SAASA,UAAT,QAA2B,aAA3B;AAMA,IAAIC,UAAJ;;AAkBA,IAAI;AACFA,EAAAA,UAAU,GAAGC,OAAO,CAAC,yBAAD,CAApB;AACD,CAFD,CAEE,OAAOC,CAAP,EAAU;AACV;AACA;AACAF,EAAAA,UAAU,GAAGG,SAAb;AACD;;AAED,IAAI,iBAACH,UAAD,wCAAC,YAAYI,cAAb,CAAJ,EAAiC;AAC/B;AACA;AACAJ,EAAAA,UAAU,GAAGG,SAAb;AACD;;AAED,IAAIH,UAAU,KAAKG,SAAf,IAA4B,CAACH,UAAU,CAACK,eAA5C,EAA6D;AAC3D;AACAL,EAAAA,UAAU,CAACK,eAAX,GAA6B,MAAM;AACjC;;AACAC,IAAAA,OAAO,CAACC,IAAR,CACER,UAAU,CACR,gGADQ,CADZ;AAKD,GAPD;AAQD;;AAED,SAASC,UAAT","sourcesContent":["import { ComponentClass } from 'react';\nimport {\n GestureUpdateEvent,\n GestureStateChangeEvent,\n} from '../gestureHandlerCommon';\nimport { tagMessage } from '../../utils';\n\nexport interface SharedValue<T> {\n value: T;\n}\n\nlet Reanimated: {\n default: {\n // Slightly modified definition copied from 'react-native-reanimated'\n // eslint-disable-next-line @typescript-eslint/ban-types\n createAnimatedComponent<P extends object>(\n component: ComponentClass<P>,\n options?: unknown\n ): ComponentClass<P>;\n };\n useEvent: (\n callback: (event: GestureUpdateEvent | GestureStateChangeEvent) => void,\n events: string[],\n rebuild: boolean\n ) => unknown;\n useSharedValue: <T>(value: T) => SharedValue<T>;\n setGestureState: (handlerTag: number, newState: number) => void;\n};\n\ntry {\n Reanimated = require('react-native-reanimated');\n} catch (e) {\n // When 'react-native-reanimated' is not available we want to quietly continue\n // @ts-ignore TS demands the variable to be initialized\n Reanimated = undefined;\n}\n\nif (!Reanimated?.useSharedValue) {\n // @ts-ignore Make sure the loaded module is actually Reanimated, if it's not\n // reset the module to undefined so we can fallback to the default implementation\n Reanimated = undefined;\n}\n\nif (Reanimated !== undefined && !Reanimated.setGestureState) {\n // The loaded module is Reanimated but it doesn't have the setGestureState defined\n Reanimated.setGestureState = () => {\n 'worklet';\n console.warn(\n tagMessage(\n 'Please use newer version of react-native-reanimated in order to control state of the gestures.'\n )\n );\n };\n}\n\nexport { Reanimated };\n"]}

View File

@@ -0,0 +1,36 @@
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
rotationChange: current.rotation
};
} else {
changePayload = {
rotationChange: current.rotation - previous.rotation
};
}
return { ...current,
...changePayload
};
}
export class RotationGesture extends ContinousBaseGesture {
constructor() {
super();
this.handlerName = 'RotationGestureHandler';
}
onChange(callback) {
// @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=rotationGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["rotationGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","rotationChange","rotation","RotationGesture","constructor","handlerName","onChange","callback","handlers"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,WAArC;;AAQA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,cAAc,EAAEJ,OAAO,CAACK;AADV,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,cAAc,EAAEJ,OAAO,CAACK,QAAR,GAAmBJ,QAAQ,CAACI;AAD9B,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMI,eAAN,SAA8BR,oBAA9B,CAGL;AACAS,EAAAA,WAAW,GAAG;AACZ;AAEA,SAAKC,WAAL,GAAmB,wBAAnB;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcZ,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMU,QAAN,CAAeC,QAAf,CAAP;AACD;;AAjBD","sourcesContent":["import { ContinousBaseGesture } from './gesture';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\ntype RotationGestureChangeEventPayload = {\n rotationChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<RotationGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<RotationGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: RotationGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n rotationChange: current.rotation,\n };\n } else {\n changePayload = {\n rotationChange: current.rotation - previous.rotation,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class RotationGesture extends ContinousBaseGesture<\n RotationGestureHandlerEventPayload,\n RotationGestureChangeEventPayload\n> {\n constructor() {\n super();\n\n this.handlerName = 'RotationGestureHandler';\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n RotationGestureHandlerEventPayload & RotationGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type RotationGestureType = InstanceType<typeof RotationGesture>;\n"]}

View File

@@ -0,0 +1,92 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture } from './gesture';
export class TapGesture extends BaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'TapGestureHandler';
this.shouldCancelWhenOutside(true);
}
/**
* Minimum number of pointers (fingers) required to be placed before the gesture activates.
* Should be a positive integer. The default value is 1.
* @param minPointers
*/
minPointers(minPointers) {
this.config.minPointers = minPointers;
return this;
}
/**
* Number of tap gestures required to activate the gesture.
* The default value is 1.
* @param count
*/
numberOfTaps(count) {
this.config.numberOfTaps = count;
return this;
}
/**
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a tap gesture.
* @param maxDist
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdistancevalue-number
*/
maxDistance(maxDist) {
this.config.maxDist = maxDist;
return this;
}
/**
* Maximum time, expressed in milliseconds, that defines how fast a finger must be released after a touch.
* The default value is 500.
* @param duration
*/
maxDuration(duration) {
this.config.maxDurationMs = duration;
return this;
}
/**
* Maximum time, expressed in milliseconds, that can pass before the next tap — if many taps are required.
* The default value is 500.
* @param delay
*/
maxDelay(delay) {
this.config.maxDelayMs = delay;
return this;
}
/**
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel along the X axis during a tap gesture.
* @param delta
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdeltaxvalue-number
*/
maxDeltaX(delta) {
this.config.maxDeltaX = delta;
return this;
}
/**
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel along the Y axis during a tap gesture.
* @param delta
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdeltayvalue-number
*/
maxDeltaY(delta) {
this.config.maxDeltaY = delta;
return this;
}
}
//# sourceMappingURL=tapGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["tapGesture.ts"],"names":["BaseGesture","TapGesture","constructor","handlerName","shouldCancelWhenOutside","minPointers","config","numberOfTaps","count","maxDistance","maxDist","maxDuration","duration","maxDurationMs","maxDelay","delay","maxDelayMs","maxDeltaX","delta","maxDeltaY"],"mappings":";;AAAA,SAA4BA,WAA5B,QAA+C,WAA/C;AAMA,OAAO,MAAMC,UAAN,SAAyBD,WAAzB,CAAoE;AAGzEE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAFwC,EAExC;;AAGZ,SAAKC,WAAL,GAAmB,mBAAnB;AACA,SAAKC,uBAAL,CAA6B,IAA7B;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACA,WAAD,EAAsB;AAC/B,SAAKC,MAAL,CAAYD,WAAZ,GAA0BA,WAA1B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEE,EAAAA,YAAY,CAACC,KAAD,EAAgB;AAC1B,SAAKF,MAAL,CAAYC,YAAZ,GAA2BC,KAA3B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACC,OAAD,EAAkB;AAC3B,SAAKJ,MAAL,CAAYI,OAAZ,GAAsBA,OAAtB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKN,MAAL,CAAYO,aAAZ,GAA4BD,QAA5B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEE,EAAAA,QAAQ,CAACC,KAAD,EAAgB;AACtB,SAAKT,MAAL,CAAYU,UAAZ,GAAyBD,KAAzB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEE,EAAAA,SAAS,CAACC,KAAD,EAAgB;AACvB,SAAKZ,MAAL,CAAYW,SAAZ,GAAwBC,KAAxB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,SAAS,CAACD,KAAD,EAAgB;AACvB,SAAKZ,MAAL,CAAYa,SAAZ,GAAwBD,KAAxB;AACA,WAAO,IAAP;AACD;;AA9EwE","sourcesContent":["import { BaseGestureConfig, BaseGesture } from './gesture';\nimport {\n TapGestureConfig,\n TapGestureHandlerEventPayload,\n} from '../TapGestureHandler';\n\nexport class TapGesture extends BaseGesture<TapGestureHandlerEventPayload> {\n public config: BaseGestureConfig & TapGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'TapGestureHandler';\n this.shouldCancelWhenOutside(true);\n }\n\n /**\n * Minimum number of pointers (fingers) required to be placed before the gesture activates.\n * Should be a positive integer. The default value is 1.\n * @param minPointers\n */\n minPointers(minPointers: number) {\n this.config.minPointers = minPointers;\n return this;\n }\n\n /**\n * Number of tap gestures required to activate the gesture.\n * The default value is 1.\n * @param count\n */\n numberOfTaps(count: number) {\n this.config.numberOfTaps = count;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a tap gesture.\n * @param maxDist\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdistancevalue-number\n */\n maxDistance(maxDist: number) {\n this.config.maxDist = maxDist;\n return this;\n }\n\n /**\n * Maximum time, expressed in milliseconds, that defines how fast a finger must be released after a touch.\n * The default value is 500.\n * @param duration\n */\n maxDuration(duration: number) {\n this.config.maxDurationMs = duration;\n return this;\n }\n\n /**\n * Maximum time, expressed in milliseconds, that can pass before the next tap — if many taps are required.\n * The default value is 500.\n * @param delay\n */\n maxDelay(delay: number) {\n this.config.maxDelayMs = delay;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel along the X axis during a tap gesture.\n * @param delta\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdeltaxvalue-number\n */\n maxDeltaX(delta: number) {\n this.config.maxDeltaX = delta;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel along the Y axis during a tap gesture.\n * @param delta\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdeltayvalue-number\n */\n maxDeltaY(delta: number) {\n this.config.maxDeltaY = delta;\n return this;\n }\n}\n\nexport type TapGestureType = InstanceType<typeof TapGesture>;\n"]}