react-native-gesture-handler 2.20.2 → 2.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/RNGestureHandler.podspec +9 -0
  2. package/ReanimatedDrawerLayout/package.json +6 -0
  3. package/android/build.gradle +19 -0
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +6 -2
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureDetector.kt +53 -21
  6. package/apple/RNGestureHandlerPointerTracker.m +4 -2
  7. package/lib/commonjs/RNGestureHandlerModule.web.js +15 -2
  8. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  9. package/lib/commonjs/components/Pressable/Pressable.js +2 -6
  10. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  11. package/lib/commonjs/components/ReanimatedDrawerLayout.js +389 -0
  12. package/lib/commonjs/components/ReanimatedDrawerLayout.js.map +1 -0
  13. package/lib/commonjs/components/ReanimatedSwipeable.js +117 -148
  14. package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
  15. package/lib/commonjs/findNodeHandle.js +12 -0
  16. package/lib/commonjs/findNodeHandle.js.map +1 -0
  17. package/lib/commonjs/findNodeHandle.web.js +40 -0
  18. package/lib/commonjs/findNodeHandle.web.js.map +1 -0
  19. package/lib/commonjs/handlers/createHandler.js +4 -2
  20. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  21. package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.web.js +51 -0
  22. package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.web.js.map +1 -0
  23. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +3 -1
  24. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
  25. package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +5 -3
  26. package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
  27. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +4 -2
  28. package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
  29. package/lib/commonjs/web/handlers/GestureHandler.js +4 -0
  30. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  31. package/lib/commonjs/web/handlers/PanGestureHandler.js +59 -0
  32. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  33. package/lib/commonjs/web/interfaces.js +10 -1
  34. package/lib/commonjs/web/interfaces.js.map +1 -1
  35. package/lib/commonjs/web/tools/EventManager.js +6 -0
  36. package/lib/commonjs/web/tools/EventManager.js.map +1 -1
  37. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -3
  38. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  39. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +5 -2
  40. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  41. package/lib/commonjs/web/tools/KeyboardEventManager.js +2 -2
  42. package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
  43. package/lib/commonjs/web/tools/PointerTracker.js +6 -30
  44. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  45. package/lib/commonjs/web/tools/WheelEventManager.js +74 -0
  46. package/lib/commonjs/web/tools/WheelEventManager.js.map +1 -0
  47. package/lib/commonjs/web/utils.js +16 -0
  48. package/lib/commonjs/web/utils.js.map +1 -1
  49. package/lib/module/RNGestureHandlerModule.web.js +16 -3
  50. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  51. package/lib/module/components/Pressable/Pressable.js +2 -6
  52. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  53. package/lib/module/components/ReanimatedDrawerLayout.js +365 -0
  54. package/lib/module/components/ReanimatedDrawerLayout.js.map +1 -0
  55. package/lib/module/components/ReanimatedSwipeable.js +119 -145
  56. package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
  57. package/lib/module/findNodeHandle.js +3 -0
  58. package/lib/module/findNodeHandle.js.map +1 -0
  59. package/lib/module/findNodeHandle.web.js +32 -0
  60. package/lib/module/findNodeHandle.web.js.map +1 -0
  61. package/lib/module/handlers/createHandler.js +2 -1
  62. package/lib/module/handlers/createHandler.js.map +1 -1
  63. package/lib/module/handlers/gestures/GestureDetector/Wrap.web.js +34 -0
  64. package/lib/module/handlers/gestures/GestureDetector/Wrap.web.js.map +1 -0
  65. package/lib/module/handlers/gestures/GestureDetector/index.js +2 -1
  66. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
  67. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +2 -2
  68. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
  69. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +1 -1
  70. package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
  71. package/lib/module/web/handlers/GestureHandler.js +4 -0
  72. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  73. package/lib/module/web/handlers/PanGestureHandler.js +58 -0
  74. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  75. package/lib/module/web/interfaces.js +8 -0
  76. package/lib/module/web/interfaces.js.map +1 -1
  77. package/lib/module/web/tools/EventManager.js +6 -0
  78. package/lib/module/web/tools/EventManager.js.map +1 -1
  79. package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -3
  80. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  81. package/lib/module/web/tools/GestureHandlerWebDelegate.js +3 -1
  82. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  83. package/lib/module/web/tools/KeyboardEventManager.js +2 -2
  84. package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
  85. package/lib/module/web/tools/PointerTracker.js +6 -30
  86. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  87. package/lib/module/web/tools/WheelEventManager.js +60 -0
  88. package/lib/module/web/tools/WheelEventManager.js.map +1 -0
  89. package/lib/module/web/utils.js +15 -0
  90. package/lib/module/web/utils.js.map +1 -1
  91. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +162 -0
  92. package/lib/typescript/components/ReanimatedSwipeable.d.ts +22 -16
  93. package/lib/typescript/findNodeHandle.d.ts +2 -0
  94. package/lib/typescript/findNodeHandle.web.d.ts +2 -0
  95. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +7 -0
  96. package/lib/typescript/web/handlers/GestureHandler.d.ts +2 -1
  97. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +5 -0
  98. package/lib/typescript/web/interfaces.d.ts +16 -0
  99. package/lib/typescript/web/tools/EventManager.d.ts +2 -0
  100. package/lib/typescript/web/tools/PointerTracker.d.ts +2 -8
  101. package/lib/typescript/web/tools/WheelEventManager.d.ts +11 -0
  102. package/lib/typescript/web/utils.d.ts +2 -1
  103. package/package.json +3 -2
  104. package/src/RNGestureHandlerModule.web.ts +23 -4
  105. package/src/components/Pressable/Pressable.tsx +2 -6
  106. package/src/components/ReanimatedDrawerLayout.tsx +741 -0
  107. package/src/components/ReanimatedSwipeable.tsx +361 -305
  108. package/src/findNodeHandle.ts +3 -0
  109. package/src/findNodeHandle.web.ts +35 -0
  110. package/src/handlers/createHandler.tsx +2 -1
  111. package/src/handlers/gestures/GestureDetector/Wrap.web.tsx +44 -0
  112. package/src/handlers/gestures/GestureDetector/index.tsx +2 -1
  113. package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -1
  114. package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +1 -1
  115. package/src/web/handlers/GestureHandler.ts +5 -1
  116. package/src/web/handlers/PanGestureHandler.ts +69 -1
  117. package/src/web/interfaces.ts +17 -0
  118. package/src/web/tools/EventManager.ts +4 -0
  119. package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
  120. package/src/web/tools/GestureHandlerWebDelegate.ts +3 -1
  121. package/src/web/tools/KeyboardEventManager.ts +2 -2
  122. package/src/web/tools/PointerTracker.ts +6 -28
  123. package/src/web/tools/WheelEventManager.ts +48 -0
  124. package/src/web/utils.ts +47 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["React","isNewWebImplementationEnabled","Gestures","HammerGestures","InteractionManager","NodeManager","HammerNodeManager","GestureHandlerWebDelegate","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Error","GestureClass","getInstance","configureInteractions","getHandler","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","HTMLElement","Component","init","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler","flushOperations"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,6BAAT,QAA8C,8BAA9C;AACA,SAASC,QAAT,EAAmBC,cAAnB,QAAyC,gBAAzC;AAEA,OAAOC,kBAAP,MAA+B,gCAA/B;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAO,KAAKC,iBAAZ,MAAmC,0BAAnC;AACA,SAASC,yBAAT,QAA0C,uCAA1C;AAEA,eAAe;AACbC,EAAAA,oBAAoB,CAACC,GAAD,EAAcC,oBAAd,EAA6C;AAC/DC,IAAAA,OAAO,CAACC,IAAR,CAAa,wBAAb,EAAuCH,GAAvC,EAA4CC,oBAA5C;AACD,GAHY;;AAIbG,EAAAA,sBAAsB,GAAG;AACvBF,IAAAA,OAAO,CAACC,IAAR,CAAa,0BAAb;AACD,GANY;;AAObE,EAAAA,oBAAoB,CAClBC,WADkB,EAElBC,UAFkB,EAGlBC,MAHkB,EAIlB;AACA,QAAIhB,6BAA6B,EAAjC,EAAqC;AACnC,UAAI,EAAEc,WAAW,IAAIb,QAAjB,CAAJ,EAAgC;AAC9B,cAAM,IAAIgB,KAAJ,CACH,iCAAgCH,WAAY,2BADzC,CAAN;AAGD;;AAED,YAAMI,YAAY,GAAGjB,QAAQ,CAACa,WAAD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AmCiB,mBAAnC,CAAuDD,SAAvD;AAEA5B,MAAAA,kBAAkB,CAACgB,WAAnB,GAAiCC,qBAAjC,CACEhB,WAAW,CAACiB,UAAZ,CAAuBN,UAAvB,CADF,EAEEgB,SAFF;AAID,KAPD,MAOO;AACL1B,MAAAA,iBAAiB,CAACgB,UAAlB,CAA6BN,UAA7B,EAAyCiB,mBAAzC,CAA6DD,SAA7D;AACD;AACF,GA5EY;;AA6EbE,EAAAA,qBAAqB,CAAClB,UAAD,EAAqB;AACxC,QAAIf,6BAA6B,EAAjC,EAAqC;AACnC,aAAOI,WAAW,CAACiB,UAAZ,CAAuBN,UAAvB,CAAP;AACD,KAFD,MAEO;AACL,aAAOV,iBAAiB,CAACgB,UAAlB,CAA6BN,UAA7B,CAAP;AACD;AACF,GAnFY;;AAoFbmB,EAAAA,kBAAkB,CAACnB,UAAD,EAAqB;AACrC,QAAIf,6BAA6B,EAAjC,EAAqC;AACnCI,MAAAA,WAAW,CAAC8B,kBAAZ,CAA+BnB,UAA/B;AACD,KAFD,MAEO;AACLV,MAAAA,iBAAiB,CAAC6B,kBAAlB,CAAqCnB,UAArC;AACD;AACF,GA1FY;;AA2Fb;AACAoB,EAAAA,eAAe,GAAG,CAAE;;AA5FP,CAAf","sourcesContent":["import React from 'react';\n\nimport type { ActionType } from './ActionType';\nimport { isNewWebImplementationEnabled } from './EnableNewWebImplementation';\nimport { Gestures, HammerGestures } from './web/Gestures';\nimport type { Config } from './web/interfaces';\nimport InteractionManager from './web/tools/InteractionManager';\nimport NodeManager from './web/tools/NodeManager';\nimport * as HammerNodeManager from './web_hammer/NodeManager';\nimport { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';\n\nexport default {\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n if (isNewWebImplementationEnabled()) {\n if (!(handlerName in Gestures)) {\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n }\n\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(\n handlerTag,\n new GestureClass(new GestureHandlerWebDelegate())\n );\n InteractionManager.getInstance().configureInteractions(\n NodeManager.getHandler(handlerTag),\n config as unknown as Config\n );\n } else {\n if (!(handlerName in HammerGestures)) {\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n }\n\n // @ts-ignore If it doesn't exist, the error is thrown\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const GestureClass = HammerGestures[handlerName];\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());\n }\n\n this.updateGestureHandler(handlerTag, config as unknown as Config);\n },\n attachGestureHandler(\n handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newView: any,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n if (\n !(newView instanceof HTMLElement || newView instanceof React.Component)\n ) {\n return;\n }\n\n if (isNewWebImplementationEnabled()) {\n // @ts-ignore Types should be HTMLElement or React.Component\n NodeManager.getHandler(handlerTag).init(newView, propsRef);\n } else {\n // @ts-ignore Types should be HTMLElement or React.Component\n HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);\n }\n },\n updateGestureHandler(handlerTag: number, newConfig: Config) {\n if (isNewWebImplementationEnabled()) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n\n InteractionManager.getInstance().configureInteractions(\n NodeManager.getHandler(handlerTag),\n newConfig\n );\n } else {\n HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n }\n },\n getGestureHandlerNode(handlerTag: number) {\n if (isNewWebImplementationEnabled()) {\n return NodeManager.getHandler(handlerTag);\n } else {\n return HammerNodeManager.getHandler(handlerTag);\n }\n },\n dropGestureHandler(handlerTag: number) {\n if (isNewWebImplementationEnabled()) {\n NodeManager.dropGestureHandler(handlerTag);\n } else {\n HammerNodeManager.dropGestureHandler(handlerTag);\n }\n },\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n flushOperations() {},\n};\n"]}
1
+ {"version":3,"sources":["RNGestureHandlerModule.web.ts"],"names":["React","isNewWebImplementationEnabled","Gestures","HammerGestures","InteractionManager","NodeManager","HammerNodeManager","GestureHandlerWebDelegate","shouldPreventDrop","handleSetJSResponder","tag","blockNativeResponder","console","warn","handleClearJSResponder","createGestureHandler","handlerName","handlerTag","config","Error","GestureClass","getInstance","configureInteractions","getHandler","updateGestureHandler","attachGestureHandler","newView","_actionType","propsRef","Element","Component","handler","constructor","name","init","setView","newConfig","updateGestureConfig","getGestureHandlerNode","dropGestureHandler","flushOperations"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,6BAAT,QAA8C,8BAA9C;AACA,SAASC,QAAT,EAAmBC,cAAnB,QAAyC,gBAAzC;AAEA,OAAOC,kBAAP,MAA+B,gCAA/B;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAO,KAAKC,iBAAZ,MAAmC,0BAAnC;AACA,SAASC,yBAAT,QAA0C,uCAA1C,C,CAEA;AACA;AACA;AACA;AACA;;AACA,IAAIC,iBAAiB,GAAG,KAAxB;AAEA,eAAe;AACbC,EAAAA,oBAAoB,CAACC,GAAD,EAAcC,oBAAd,EAA6C;AAC/DC,IAAAA,OAAO,CAACC,IAAR,CAAa,wBAAb,EAAuCH,GAAvC,EAA4CC,oBAA5C;AACD,GAHY;;AAIbG,EAAAA,sBAAsB,GAAG;AACvBF,IAAAA,OAAO,CAACC,IAAR,CAAa,0BAAb;AACD,GANY;;AAObE,EAAAA,oBAAoB,CAClBC,WADkB,EAElBC,UAFkB,EAGlBC,MAHkB,EAIlB;AACA,QAAIjB,6BAA6B,EAAjC,EAAqC;AACnC,UAAI,EAAEe,WAAW,IAAId,QAA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G,CAAE;;AAxGP,CAAf","sourcesContent":["import React from 'react';\n\nimport type { ActionType } from './ActionType';\nimport { isNewWebImplementationEnabled } from './EnableNewWebImplementation';\nimport { Gestures, HammerGestures } from './web/Gestures';\nimport type { Config } from './web/interfaces';\nimport InteractionManager from './web/tools/InteractionManager';\nimport NodeManager from './web/tools/NodeManager';\nimport * as HammerNodeManager from './web_hammer/NodeManager';\nimport { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';\n\n// init method is called inside attachGestureHandler function. However, this function may\n// fail when received view is not valid HTML element. On the other hand, dropGestureHandler\n// will be called even if attach failed, which will result in crash.\n//\n// We use this flag to check whether or not dropGestureHandler should be called.\nlet shouldPreventDrop = false;\n\nexport default {\n handleSetJSResponder(tag: number, blockNativeResponder: boolean) {\n console.warn('handleSetJSResponder: ', tag, blockNativeResponder);\n },\n handleClearJSResponder() {\n console.warn('handleClearJSResponder: ');\n },\n createGestureHandler<T>(\n handlerName: keyof typeof Gestures,\n handlerTag: number,\n config: T\n ) {\n if (isNewWebImplementationEnabled()) {\n if (!(handlerName in Gestures)) {\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n }\n\n const GestureClass = Gestures[handlerName];\n NodeManager.createGestureHandler(\n handlerTag,\n new GestureClass(new GestureHandlerWebDelegate())\n );\n InteractionManager.getInstance().configureInteractions(\n NodeManager.getHandler(handlerTag),\n config as unknown as Config\n );\n } else {\n if (!(handlerName in HammerGestures)) {\n throw new Error(\n `react-native-gesture-handler: ${handlerName} is not supported on web.`\n );\n }\n\n // @ts-ignore If it doesn't exist, the error is thrown\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const GestureClass = HammerGestures[handlerName];\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());\n }\n\n this.updateGestureHandler(handlerTag, config as unknown as Config);\n },\n attachGestureHandler(\n handlerTag: number,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n newView: any,\n _actionType: ActionType,\n propsRef: React.RefObject<unknown>\n ) {\n if (!(newView instanceof Element || newView instanceof React.Component)) {\n shouldPreventDrop = true;\n\n const handler = isNewWebImplementationEnabled()\n ? NodeManager.getHandler(handlerTag)\n : HammerNodeManager.getHandler(handlerTag);\n\n const handlerName = handler.constructor.name;\n\n throw new Error(\n `${handlerName} with tag ${handlerTag} received child that is not valid HTML element.`\n );\n }\n\n if (isNewWebImplementationEnabled()) {\n // @ts-ignore Types should be HTMLElement or React.Component\n NodeManager.getHandler(handlerTag).init(newView, propsRef);\n } else {\n // @ts-ignore Types should be HTMLElement or React.Component\n HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);\n }\n },\n updateGestureHandler(handlerTag: number, newConfig: Config) {\n if (isNewWebImplementationEnabled()) {\n NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n\n InteractionManager.getInstance().configureInteractions(\n NodeManager.getHandler(handlerTag),\n newConfig\n );\n } else {\n HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);\n }\n },\n getGestureHandlerNode(handlerTag: number) {\n if (isNewWebImplementationEnabled()) {\n return NodeManager.getHandler(handlerTag);\n } else {\n return HammerNodeManager.getHandler(handlerTag);\n }\n },\n dropGestureHandler(handlerTag: number) {\n if (shouldPreventDrop) {\n return;\n }\n\n if (isNewWebImplementationEnabled()) {\n NodeManager.dropGestureHandler(handlerTag);\n } else {\n HammerNodeManager.dropGestureHandler(handlerTag);\n }\n },\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n flushOperations() {},\n};\n"]}
@@ -212,7 +212,7 @@ export default function Pressable(props) {
212
212
 
213
213
  const buttonGesture = useMemo(() => Gesture.Native().onBegin(() => {
214
214
  // Android sets BEGAN state on press down
215
- if (Platform.OS === 'android') {
215
+ if (Platform.OS === 'android' || Platform.OS === 'macos') {
216
216
  isTouchPropagationAllowed.current = true;
217
217
  }
218
218
  }).onStart(() => {
@@ -259,11 +259,7 @@ export default function Pressable(props) {
259
259
  gesture.enabled(isPressableEnabled);
260
260
  gesture.runOnJS(true);
261
261
  gesture.hitSlop(appliedHitSlop);
262
- gesture.shouldCancelWhenOutside(false);
263
-
264
- if (Platform.OS !== 'web') {
265
- gesture.shouldCancelWhenOutside(true);
266
- }
262
+ gesture.shouldCancelWhenOutside(Platform.OS === 'web' ? false : true);
267
263
  } // Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area
268
264
 
269
265
 
@@ -1 +1 @@
1
- {"version":3,"sources":["Pressable.tsx"],"names":["React","useCallback","useMemo","useRef","useState","GestureObjects","Gesture","GestureDetector","Platform","processColor","NativeButton","numberAsInset","gestureToPressableEvent","isTouchWithinInset","gestureTouchToPressableEvent","addInsets","PressabilityDebugView","INT32_MAX","DEFAULT_LONG_PRESS_DURATION","Pressable","props","testOnly_pressed","hitSlop","pressRetentionOffset","delayHoverIn","onHoverIn","delayHoverOut","onHoverOut","delayLongPress","unstable_pressDelay","onPress","onPressIn","onPressOut","onLongPress","style","children","android_disableSound","android_ripple","disabled","remainingProps","pressedState","setPressedState","pressableRef","isPressCallbackEnabled","hasPassedBoundsChecks","shouldPreventNativeEffects","normalizedHitSlop","normalizedPressRetentionOffset","hoverInTimeout","hoverOutTimeout","hoverGesture","Hover","manualActivation","cancelsTouchesInView","onBegin","event","current","clearTimeout","setTimeout","onFinalize","pressDelayTimeoutRef","isTouchPropagationAllowed","deferredEventPayload","pressInHandler","handlingOnTouchesDown","pressOutHandler","nativeEvent","touches","length","changedTouches","longPressTimeoutRef","onEndHandlingTouchesDown","cancelledMidPress","activateLongPress","longPressMinDuration","pressAndTouchGesture","LongPress","minDuration","maxDistance","onTouchesDown","measure","_x","_y","width","height","at","onTouchesUp","onTouchesCancelled","allTouches","buttonGesture","Native","OS","onStart","appliedHitSlop","isPressableEnabled","gestures","gesture","enabled","runOnJS","shouldCancelWhenOutside","Simultaneous","defaultRippleColor","undefined","pointerStyle","cursor","styleProp","pressed","childrenProp","color","radius","__DEV__"],"m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F,uBAAEA,cAAc,CAAEwE,MAAlB,yEAA4BP,SAP1C;AAQE,IAAA,KAAK,EAAE,CAACC,YAAD,EAAeE,SAAf;AART,MASGE,YATH,EAUGG,OAAO,gBACN,oBAAC,qBAAD;AAAuB,IAAA,KAAK,EAAC,KAA7B;AAAmC,IAAA,OAAO,EAAEhE;AAA5C,IADM,GAEJ,IAZN,CADF,CADF;AAkBD","sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects';\nimport { GestureDetector } from '../../handlers/gestures/GestureDetector';\nimport { PressableEvent, PressableProps } from './PressableProps';\nimport {\n Insets,\n Platform,\n StyleProp,\n View,\n ViewStyle,\n processColor,\n} from 'react-native';\nimport NativeButton from '../GestureHandlerButton';\nimport {\n numberAsInset,\n gestureToPressableEvent,\n isTouchWithinInset,\n gestureTouchToPressableEvent,\n addInsets,\n} from './utils';\nimport { PressabilityDebugView } from '../../handlers/PressabilityDebugView';\nimport { GestureTouchEvent } from '../../handlers/gestureHandlerCommon';\nimport { INT32_MAX } from '../../utils';\n\nconst DEFAULT_LONG_PRESS_DURATION = 500;\n\nexport default function Pressable(props: PressableProps) {\n const {\n testOnly_pressed,\n hitSlop,\n pressRetentionOffset,\n delayHoverIn,\n onHoverIn,\n delayHoverOut,\n onHoverOut,\n delayLongPress,\n unstable_pressDelay,\n onPress,\n onPressIn,\n onPressOut,\n onLongPress,\n style,\n children,\n android_disableSound,\n android_ripple,\n disabled,\n ...remainingProps\n } = props;\n\n const [pressedState, setPressedState] = useState(testOnly_pressed ?? false);\n\n const pressableRef = useRef<View>(null);\n\n // Disabled when onLongPress has been called\n const isPressCallbackEnabled = useRef<boolean>(true);\n const hasPassedBoundsChecks = useRef<boolean>(false);\n const shouldPreventNativeEffects = useRef<boolean>(false);\n\n const normalizedHitSlop: Insets = useMemo(\n () =>\n typeof hitSlop === 'number' ? numberAsInset(hitSlop) : hitSlop ?? {},\n [hitSlop]\n );\n\n const normalizedPressRetentionOffset: Insets = useMemo(\n () =>\n typeof pressRetentionOffset === 'number'\n ? numberAsInset(pressRetentionOffset)\n : pressRetentionOffset ?? {},\n [pressRetentionOffset]\n );\n\n const hoverInTimeout = useRef<number | null>(null);\n const hoverOutTimeout = useRef<number | null>(null);\n\n const hoverGesture = useMemo(\n () =>\n Gesture.Hover()\n .manualActivation(true) // Stops Hover from blocking Native gesture activation on web\n .cancelsTouchesInView(false)\n .onBegin((event) => {\n if (hoverOutTimeout.current) {\n clearTimeout(hoverOutTimeout.current);\n }\n if (delayHoverIn) {\n hoverInTimeout.current = setTimeout(\n () => onHoverIn?.(gestureToPressableEvent(event)),\n delayHoverIn\n );\n return;\n }\n onHoverIn?.(gestureToPressableEvent(event));\n })\n .onFinalize((event) => {\n if (hoverInTimeout.current) {\n clearTimeout(hoverInTimeout.current);\n }\n if (delayHoverOut) {\n hoverOutTimeout.current = setTimeout(\n () => onHoverOut?.(gestureToPressableEvent(event)),\n delayHoverOut\n );\n return;\n }\n onHoverOut?.(gestureToPressableEvent(event));\n }),\n [delayHoverIn, delayHoverOut, onHoverIn, onHoverOut]\n );\n\n const pressDelayTimeoutRef = useRef<number | null>(null);\n const isTouchPropagationAllowed = useRef<boolean>(false);\n\n // iOS only: due to varying flow of gestures, events sometimes have to be saved for later use\n const deferredEventPayload = useRef<PressableEvent | null>(null);\n\n const pressInHandler = useCallback(\n (event: PressableEvent) => {\n if (handlingOnTouchesDown.current) {\n deferredEventPayload.current = event;\n }\n\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n deferredEventPayload.current = null;\n\n onPressIn?.(event);\n isPressCallbackEnabled.current = true;\n pressDelayTimeoutRef.current = null;\n setPressedState(true);\n },\n [onPressIn]\n );\n\n const pressOutHandler = useCallback(\n (event: PressableEvent) => {\n if (\n !hasPassedBoundsChecks.current ||\n event.nativeEvent.touches.length >\n event.nativeEvent.changedTouches.length\n ) {\n return;\n }\n\n if (unstable_pressDelay && pressDelayTimeoutRef.current !== null) {\n // When delay is preemptively finished by lifting touches,\n // we want to immediately activate it's effects - pressInHandler,\n // even though we are located at the pressOutHandler\n clearTimeout(pressDelayTimeoutRef.current);\n pressInHandler(event);\n }\n\n if (deferredEventPayload.current) {\n onPressIn?.(deferredEventPayload.current);\n deferredEventPayload.current = null;\n }\n\n onPressOut?.(event);\n\n if (isPressCallbackEnabled.current) {\n onPress?.(event);\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n\n isTouchPropagationAllowed.current = false;\n hasPassedBoundsChecks.current = false;\n isPressCallbackEnabled.current = true;\n setPressedState(false);\n },\n [onPress, onPressIn, onPressOut, pressInHandler, unstable_pressDelay]\n );\n\n const handlingOnTouchesDown = useRef<boolean>(false);\n const onEndHandlingTouchesDown = useRef<(() => void) | null>(null);\n const cancelledMidPress = useRef<boolean>(false);\n\n const activateLongPress = useCallback(\n (event: GestureTouchEvent) => {\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n onLongPress?.(gestureTouchToPressableEvent(event));\n isPressCallbackEnabled.current = false;\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n },\n [onLongPress]\n );\n\n const longPressTimeoutRef = useRef<number | null>(null);\n const longPressMinDuration =\n (delayLongPress ?? DEFAULT_LONG_PRESS_DURATION) +\n (unstable_pressDelay ?? 0);\n\n const pressAndTouchGesture = useMemo(\n () =>\n Gesture.LongPress()\n .minDuration(INT32_MAX) // Stops long press from blocking native gesture\n .maxDistance(INT32_MAX) // Stops long press from cancelling after set distance\n .cancelsTouchesInView(false)\n .onTouchesDown((event) => {\n handlingOnTouchesDown.current = true;\n pressableRef.current?.measure((_x, _y, width, height) => {\n if (\n !isTouchWithinInset(\n {\n width,\n height,\n },\n normalizedHitSlop,\n event.changedTouches.at(-1)\n ) ||\n hasPassedBoundsChecks.current ||\n cancelledMidPress.current\n ) {\n cancelledMidPress.current = false;\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n return;\n }\n\n hasPassedBoundsChecks.current = true;\n\n // In case of multiple touches, the first one starts long press gesture\n if (longPressTimeoutRef.current === null) {\n // Start long press gesture timer\n longPressTimeoutRef.current = setTimeout(\n () => activateLongPress(event),\n longPressMinDuration\n );\n }\n\n if (unstable_pressDelay) {\n pressDelayTimeoutRef.current = setTimeout(() => {\n pressInHandler(gestureTouchToPressableEvent(event));\n }, unstable_pressDelay);\n } else {\n pressInHandler(gestureTouchToPressableEvent(event));\n }\n\n onEndHandlingTouchesDown.current?.();\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n });\n })\n .onTouchesUp((event) => {\n if (handlingOnTouchesDown.current) {\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n // On iOS, short taps will make LongPress gesture call onTouchesUp before Native gesture calls onStart\n // This variable ensures that onStart isn't detected as the first gesture since Pressable is pressed.\n if (deferredEventPayload.current !== null) {\n shouldPreventNativeEffects.current = true;\n }\n pressOutHandler(gestureTouchToPressableEvent(event));\n })\n .onTouchesCancelled((event) => {\n isPressCallbackEnabled.current = false;\n\n if (handlingOnTouchesDown.current) {\n cancelledMidPress.current = true;\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n\n if (\n !hasPassedBoundsChecks.current ||\n event.allTouches.length > event.changedTouches.length\n ) {\n return;\n }\n\n pressOutHandler(gestureTouchToPressableEvent(event));\n }),\n [\n activateLongPress,\n longPressMinDuration,\n normalizedHitSlop,\n pressInHandler,\n pressOutHandler,\n unstable_pressDelay,\n ]\n );\n\n // RNButton is placed inside ButtonGesture to enable Android's ripple and to capture non-propagating events\n const buttonGesture = useMemo(\n () =>\n Gesture.Native()\n .onBegin(() => {\n // Android sets BEGAN state on press down\n if (Platform.OS === 'android') {\n isTouchPropagationAllowed.current = true;\n }\n })\n .onStart(() => {\n if (Platform.OS === 'web') {\n isTouchPropagationAllowed.current = true;\n }\n\n // iOS sets ACTIVE state on press down\n if (Platform.OS !== 'ios') {\n return;\n }\n\n if (deferredEventPayload.current) {\n isTouchPropagationAllowed.current = true;\n\n if (hasPassedBoundsChecks.current) {\n pressInHandler(deferredEventPayload.current);\n deferredEventPayload.current = null;\n } else {\n pressOutHandler(deferredEventPayload.current);\n isTouchPropagationAllowed.current = false;\n }\n\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n isTouchPropagationAllowed.current = true;\n return;\n }\n\n if (shouldPreventNativeEffects.current) {\n shouldPreventNativeEffects.current = false;\n return;\n }\n\n isTouchPropagationAllowed.current = true;\n }),\n [pressInHandler, pressOutHandler]\n );\n\n const appliedHitSlop = addInsets(\n normalizedHitSlop,\n normalizedPressRetentionOffset\n );\n\n const isPressableEnabled = disabled !== true;\n\n const gestures = [pressAndTouchGesture, hoverGesture, buttonGesture];\n\n for (const gesture of gestures) {\n gesture.enabled(isPressableEnabled);\n gesture.runOnJS(true);\n gesture.hitSlop(appliedHitSlop);\n gesture.shouldCancelWhenOutside(false);\n\n if (Platform.OS !== 'web') {\n gesture.shouldCancelWhenOutside(true);\n }\n }\n\n // Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area\n buttonGesture.hitSlop(normalizedHitSlop);\n\n const gesture = Gesture.Simultaneous(...gestures);\n\n const defaultRippleColor = android_ripple ? undefined : 'transparent';\n\n // `cursor: 'pointer'` on `RNButton` crashes iOS\n const pointerStyle: StyleProp<ViewStyle> =\n Platform.OS === 'web' ? { cursor: 'pointer' } : {};\n\n const styleProp =\n typeof style === 'function' ? style({ pressed: pressedState }) : style;\n\n const childrenProp =\n typeof children === 'function'\n ? children({ pressed: pressedState })\n : children;\n\n return (\n <GestureDetector gesture={gesture}>\n <NativeButton\n {...remainingProps}\n ref={pressableRef}\n hitSlop={appliedHitSlop}\n enabled={isPressableEnabled}\n touchSoundDisabled={android_disableSound ?? undefined}\n rippleColor={processColor(android_ripple?.color ?? defaultRippleColor)}\n rippleRadius={android_ripple?.radius ?? undefined}\n style={[pointerStyle, styleProp]}>\n {childrenProp}\n {__DEV__ ? (\n <PressabilityDebugView color=\"red\" hitSlop={normalizedHitSlop} />\n ) : null}\n </NativeButton>\n </GestureDetector>\n );\n}\n"]}
1
+ {"version":3,"sources":["Pressable.tsx"],"names":["React","useCallback","useMemo","useRef","useState","GestureObjects","Gesture","GestureDetector","Platform","processColor","NativeButton","numberAsInset","gestureToPressableEvent","isTouchWithinInset","gestureTouchToPressableEvent","addInsets","PressabilityDebugView","INT32_MAX","DEFAULT_LONG_PRESS_DURATION","Pressable","props","testOnly_pressed","hitSlop","pressRetentionOffset","delayHoverIn","onHoverIn","delayHoverOut","onHoverOut","delayLongPress","unstable_pressDelay","onPress","onPressIn","onPressOut","onLongPress","style","children","android_disableSound","android_ripple","disabled","remainingProps","pressedState","setPressedState","pressableRef","isPressCallbackEnabled","hasPassedBoundsChecks","shouldPreventNativeEffects","normalizedHitSlop","normalizedPressRetentionOffset","hoverInTimeout","hoverOutTimeout","hoverGesture","Hover","manualActivation","cancelsTouchesInView","onBegin","event","current","clearTimeout","setTimeout","onFinalize","pressDelayTimeoutRef","isTouchPropagationAllowed","deferredEventPayload","pressInHandler","handlingOnTouchesDown","pressOutHandler","nativeEvent","touches","length","changedTouches","longPressTimeoutRef","onEndHandlingTouchesDown","cancelledMidPress","activateLongPress","longPressMinDuration","pressAndTouchGesture","LongPress","minDuration","maxDistance","onTouchesDown","measure","_x","_y","width","height","at","onTouchesUp","onTouchesCancelled","allTouches","buttonGesture","Native","OS","onStart","appliedHitSlop","isPressableEnabled","gestures","gesture","enabled","runOnJS","shouldCancelWhenOutside","Simultaneous","defaultRippleColor","undefined","pointerStyle","cursor","styleProp","pressed","childrenProp","color","radius","__DEV__"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,OAA7B,EAAsCC,MAAtC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C,YAAD,EAAeE,SAAf;AART,MASGE,YATH,EAUGG,OAAO,gBACN,oBAAC,qBAAD;AAAuB,IAAA,KAAK,EAAC,KAA7B;AAAmC,IAAA,OAAO,EAAEhE;AAA5C,IADM,GAEJ,IAZN,CADF,CADF;AAkBD","sourcesContent":["import React, { useCallback, useMemo, useRef, useState } from 'react';\nimport { GestureObjects as Gesture } from '../../handlers/gestures/gestureObjects';\nimport { GestureDetector } from '../../handlers/gestures/GestureDetector';\nimport { PressableEvent, PressableProps } from './PressableProps';\nimport {\n Insets,\n Platform,\n StyleProp,\n View,\n ViewStyle,\n processColor,\n} from 'react-native';\nimport NativeButton from '../GestureHandlerButton';\nimport {\n numberAsInset,\n gestureToPressableEvent,\n isTouchWithinInset,\n gestureTouchToPressableEvent,\n addInsets,\n} from './utils';\nimport { PressabilityDebugView } from '../../handlers/PressabilityDebugView';\nimport { GestureTouchEvent } from '../../handlers/gestureHandlerCommon';\nimport { INT32_MAX } from '../../utils';\n\nconst DEFAULT_LONG_PRESS_DURATION = 500;\n\nexport default function Pressable(props: PressableProps) {\n const {\n testOnly_pressed,\n hitSlop,\n pressRetentionOffset,\n delayHoverIn,\n onHoverIn,\n delayHoverOut,\n onHoverOut,\n delayLongPress,\n unstable_pressDelay,\n onPress,\n onPressIn,\n onPressOut,\n onLongPress,\n style,\n children,\n android_disableSound,\n android_ripple,\n disabled,\n ...remainingProps\n } = props;\n\n const [pressedState, setPressedState] = useState(testOnly_pressed ?? false);\n\n const pressableRef = useRef<View>(null);\n\n // Disabled when onLongPress has been called\n const isPressCallbackEnabled = useRef<boolean>(true);\n const hasPassedBoundsChecks = useRef<boolean>(false);\n const shouldPreventNativeEffects = useRef<boolean>(false);\n\n const normalizedHitSlop: Insets = useMemo(\n () =>\n typeof hitSlop === 'number' ? numberAsInset(hitSlop) : hitSlop ?? {},\n [hitSlop]\n );\n\n const normalizedPressRetentionOffset: Insets = useMemo(\n () =>\n typeof pressRetentionOffset === 'number'\n ? numberAsInset(pressRetentionOffset)\n : pressRetentionOffset ?? {},\n [pressRetentionOffset]\n );\n\n const hoverInTimeout = useRef<number | null>(null);\n const hoverOutTimeout = useRef<number | null>(null);\n\n const hoverGesture = useMemo(\n () =>\n Gesture.Hover()\n .manualActivation(true) // Stops Hover from blocking Native gesture activation on web\n .cancelsTouchesInView(false)\n .onBegin((event) => {\n if (hoverOutTimeout.current) {\n clearTimeout(hoverOutTimeout.current);\n }\n if (delayHoverIn) {\n hoverInTimeout.current = setTimeout(\n () => onHoverIn?.(gestureToPressableEvent(event)),\n delayHoverIn\n );\n return;\n }\n onHoverIn?.(gestureToPressableEvent(event));\n })\n .onFinalize((event) => {\n if (hoverInTimeout.current) {\n clearTimeout(hoverInTimeout.current);\n }\n if (delayHoverOut) {\n hoverOutTimeout.current = setTimeout(\n () => onHoverOut?.(gestureToPressableEvent(event)),\n delayHoverOut\n );\n return;\n }\n onHoverOut?.(gestureToPressableEvent(event));\n }),\n [delayHoverIn, delayHoverOut, onHoverIn, onHoverOut]\n );\n\n const pressDelayTimeoutRef = useRef<number | null>(null);\n const isTouchPropagationAllowed = useRef<boolean>(false);\n\n // iOS only: due to varying flow of gestures, events sometimes have to be saved for later use\n const deferredEventPayload = useRef<PressableEvent | null>(null);\n\n const pressInHandler = useCallback(\n (event: PressableEvent) => {\n if (handlingOnTouchesDown.current) {\n deferredEventPayload.current = event;\n }\n\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n deferredEventPayload.current = null;\n\n onPressIn?.(event);\n isPressCallbackEnabled.current = true;\n pressDelayTimeoutRef.current = null;\n setPressedState(true);\n },\n [onPressIn]\n );\n\n const pressOutHandler = useCallback(\n (event: PressableEvent) => {\n if (\n !hasPassedBoundsChecks.current ||\n event.nativeEvent.touches.length >\n event.nativeEvent.changedTouches.length\n ) {\n return;\n }\n\n if (unstable_pressDelay && pressDelayTimeoutRef.current !== null) {\n // When delay is preemptively finished by lifting touches,\n // we want to immediately activate it's effects - pressInHandler,\n // even though we are located at the pressOutHandler\n clearTimeout(pressDelayTimeoutRef.current);\n pressInHandler(event);\n }\n\n if (deferredEventPayload.current) {\n onPressIn?.(deferredEventPayload.current);\n deferredEventPayload.current = null;\n }\n\n onPressOut?.(event);\n\n if (isPressCallbackEnabled.current) {\n onPress?.(event);\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n\n isTouchPropagationAllowed.current = false;\n hasPassedBoundsChecks.current = false;\n isPressCallbackEnabled.current = true;\n setPressedState(false);\n },\n [onPress, onPressIn, onPressOut, pressInHandler, unstable_pressDelay]\n );\n\n const handlingOnTouchesDown = useRef<boolean>(false);\n const onEndHandlingTouchesDown = useRef<(() => void) | null>(null);\n const cancelledMidPress = useRef<boolean>(false);\n\n const activateLongPress = useCallback(\n (event: GestureTouchEvent) => {\n if (!isTouchPropagationAllowed.current) {\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n onLongPress?.(gestureTouchToPressableEvent(event));\n isPressCallbackEnabled.current = false;\n }\n\n if (longPressTimeoutRef.current) {\n clearTimeout(longPressTimeoutRef.current);\n longPressTimeoutRef.current = null;\n }\n },\n [onLongPress]\n );\n\n const longPressTimeoutRef = useRef<number | null>(null);\n const longPressMinDuration =\n (delayLongPress ?? DEFAULT_LONG_PRESS_DURATION) +\n (unstable_pressDelay ?? 0);\n\n const pressAndTouchGesture = useMemo(\n () =>\n Gesture.LongPress()\n .minDuration(INT32_MAX) // Stops long press from blocking native gesture\n .maxDistance(INT32_MAX) // Stops long press from cancelling after set distance\n .cancelsTouchesInView(false)\n .onTouchesDown((event) => {\n handlingOnTouchesDown.current = true;\n pressableRef.current?.measure((_x, _y, width, height) => {\n if (\n !isTouchWithinInset(\n {\n width,\n height,\n },\n normalizedHitSlop,\n event.changedTouches.at(-1)\n ) ||\n hasPassedBoundsChecks.current ||\n cancelledMidPress.current\n ) {\n cancelledMidPress.current = false;\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n return;\n }\n\n hasPassedBoundsChecks.current = true;\n\n // In case of multiple touches, the first one starts long press gesture\n if (longPressTimeoutRef.current === null) {\n // Start long press gesture timer\n longPressTimeoutRef.current = setTimeout(\n () => activateLongPress(event),\n longPressMinDuration\n );\n }\n\n if (unstable_pressDelay) {\n pressDelayTimeoutRef.current = setTimeout(() => {\n pressInHandler(gestureTouchToPressableEvent(event));\n }, unstable_pressDelay);\n } else {\n pressInHandler(gestureTouchToPressableEvent(event));\n }\n\n onEndHandlingTouchesDown.current?.();\n onEndHandlingTouchesDown.current = null;\n handlingOnTouchesDown.current = false;\n });\n })\n .onTouchesUp((event) => {\n if (handlingOnTouchesDown.current) {\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n // On iOS, short taps will make LongPress gesture call onTouchesUp before Native gesture calls onStart\n // This variable ensures that onStart isn't detected as the first gesture since Pressable is pressed.\n if (deferredEventPayload.current !== null) {\n shouldPreventNativeEffects.current = true;\n }\n pressOutHandler(gestureTouchToPressableEvent(event));\n })\n .onTouchesCancelled((event) => {\n isPressCallbackEnabled.current = false;\n\n if (handlingOnTouchesDown.current) {\n cancelledMidPress.current = true;\n onEndHandlingTouchesDown.current = () =>\n pressOutHandler(gestureTouchToPressableEvent(event));\n return;\n }\n\n if (\n !hasPassedBoundsChecks.current ||\n event.allTouches.length > event.changedTouches.length\n ) {\n return;\n }\n\n pressOutHandler(gestureTouchToPressableEvent(event));\n }),\n [\n activateLongPress,\n longPressMinDuration,\n normalizedHitSlop,\n pressInHandler,\n pressOutHandler,\n unstable_pressDelay,\n ]\n );\n\n // RNButton is placed inside ButtonGesture to enable Android's ripple and to capture non-propagating events\n const buttonGesture = useMemo(\n () =>\n Gesture.Native()\n .onBegin(() => {\n // Android sets BEGAN state on press down\n if (Platform.OS === 'android' || Platform.OS === 'macos') {\n isTouchPropagationAllowed.current = true;\n }\n })\n .onStart(() => {\n if (Platform.OS === 'web') {\n isTouchPropagationAllowed.current = true;\n }\n\n // iOS sets ACTIVE state on press down\n if (Platform.OS !== 'ios') {\n return;\n }\n\n if (deferredEventPayload.current) {\n isTouchPropagationAllowed.current = true;\n\n if (hasPassedBoundsChecks.current) {\n pressInHandler(deferredEventPayload.current);\n deferredEventPayload.current = null;\n } else {\n pressOutHandler(deferredEventPayload.current);\n isTouchPropagationAllowed.current = false;\n }\n\n return;\n }\n\n if (hasPassedBoundsChecks.current) {\n isTouchPropagationAllowed.current = true;\n return;\n }\n\n if (shouldPreventNativeEffects.current) {\n shouldPreventNativeEffects.current = false;\n return;\n }\n\n isTouchPropagationAllowed.current = true;\n }),\n [pressInHandler, pressOutHandler]\n );\n\n const appliedHitSlop = addInsets(\n normalizedHitSlop,\n normalizedPressRetentionOffset\n );\n\n const isPressableEnabled = disabled !== true;\n\n const gestures = [pressAndTouchGesture, hoverGesture, buttonGesture];\n\n for (const gesture of gestures) {\n gesture.enabled(isPressableEnabled);\n gesture.runOnJS(true);\n gesture.hitSlop(appliedHitSlop);\n gesture.shouldCancelWhenOutside(Platform.OS === 'web' ? false : true);\n }\n\n // Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area\n buttonGesture.hitSlop(normalizedHitSlop);\n\n const gesture = Gesture.Simultaneous(...gestures);\n\n const defaultRippleColor = android_ripple ? undefined : 'transparent';\n\n // `cursor: 'pointer'` on `RNButton` crashes iOS\n const pointerStyle: StyleProp<ViewStyle> =\n Platform.OS === 'web' ? { cursor: 'pointer' } : {};\n\n const styleProp =\n typeof style === 'function' ? style({ pressed: pressedState }) : style;\n\n const childrenProp =\n typeof children === 'function'\n ? children({ pressed: pressedState })\n : children;\n\n return (\n <GestureDetector gesture={gesture}>\n <NativeButton\n {...remainingProps}\n ref={pressableRef}\n hitSlop={appliedHitSlop}\n enabled={isPressableEnabled}\n touchSoundDisabled={android_disableSound ?? undefined}\n rippleColor={processColor(android_ripple?.color ?? defaultRippleColor)}\n rippleRadius={android_ripple?.radius ?? undefined}\n style={[pointerStyle, styleProp]}>\n {childrenProp}\n {__DEV__ ? (\n <PressabilityDebugView color=\"red\" hitSlop={normalizedHitSlop} />\n ) : null}\n </NativeButton>\n </GestureDetector>\n );\n}\n"]}
@@ -0,0 +1,365 @@
1
+ // This component is based on RN's DrawerLayoutAndroid API
2
+ // It's cross-compatible with all platforms despite
3
+ // `DrawerLayoutAndroid` only being available on android
4
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
5
+ import { StyleSheet, Keyboard, StatusBar, I18nManager, Platform } from 'react-native';
6
+ import Animated, { Extrapolation, interpolate, runOnJS, useAnimatedProps, useAnimatedStyle, useDerivedValue, useSharedValue, withSpring } from 'react-native-reanimated';
7
+ import { GestureObjects as Gesture } from '../handlers/gestures/gestureObjects';
8
+ import { GestureDetector } from '../handlers/gestures/GestureDetector';
9
+ import { MouseButton } from '../handlers/gestureHandlerCommon';
10
+ const DRAG_TOSS = 0.05;
11
+ export let DrawerPosition;
12
+
13
+ (function (DrawerPosition) {
14
+ DrawerPosition[DrawerPosition["LEFT"] = 0] = "LEFT";
15
+ DrawerPosition[DrawerPosition["RIGHT"] = 1] = "RIGHT";
16
+ })(DrawerPosition || (DrawerPosition = {}));
17
+
18
+ export let DrawerState;
19
+
20
+ (function (DrawerState) {
21
+ DrawerState[DrawerState["IDLE"] = 0] = "IDLE";
22
+ DrawerState[DrawerState["DRAGGING"] = 1] = "DRAGGING";
23
+ DrawerState[DrawerState["SETTLING"] = 2] = "SETTLING";
24
+ })(DrawerState || (DrawerState = {}));
25
+
26
+ export let DrawerType;
27
+
28
+ (function (DrawerType) {
29
+ DrawerType[DrawerType["FRONT"] = 0] = "FRONT";
30
+ DrawerType[DrawerType["BACK"] = 1] = "BACK";
31
+ DrawerType[DrawerType["SLIDE"] = 2] = "SLIDE";
32
+ })(DrawerType || (DrawerType = {}));
33
+
34
+ export let DrawerLockMode;
35
+
36
+ (function (DrawerLockMode) {
37
+ DrawerLockMode[DrawerLockMode["UNLOCKED"] = 0] = "UNLOCKED";
38
+ DrawerLockMode[DrawerLockMode["LOCKED_CLOSED"] = 1] = "LOCKED_CLOSED";
39
+ DrawerLockMode[DrawerLockMode["LOCKED_OPEN"] = 2] = "LOCKED_OPEN";
40
+ })(DrawerLockMode || (DrawerLockMode = {}));
41
+
42
+ export let DrawerKeyboardDismissMode;
43
+
44
+ (function (DrawerKeyboardDismissMode) {
45
+ DrawerKeyboardDismissMode[DrawerKeyboardDismissMode["NONE"] = 0] = "NONE";
46
+ DrawerKeyboardDismissMode[DrawerKeyboardDismissMode["ON_DRAG"] = 1] = "ON_DRAG";
47
+ })(DrawerKeyboardDismissMode || (DrawerKeyboardDismissMode = {}));
48
+
49
+ const defaultProps = {
50
+ drawerWidth: 200,
51
+ drawerPosition: DrawerPosition.LEFT,
52
+ drawerType: DrawerType.FRONT,
53
+ edgeWidth: 20,
54
+ minSwipeDistance: 3,
55
+ overlayColor: 'rgba(0, 0, 0, 0.7)',
56
+ drawerLockMode: DrawerLockMode.UNLOCKED,
57
+ enableTrackpadTwoFingerGesture: false,
58
+ activeCursor: 'auto',
59
+ mouseButton: MouseButton.LEFT,
60
+ statusBarAnimation: 'slide'
61
+ };
62
+ const DrawerLayout = /*#__PURE__*/forwardRef(function DrawerLayout(props, ref) {
63
+ const [containerWidth, setContainerWidth] = useState(0);
64
+ const [drawerState, setDrawerState] = useState(DrawerState.IDLE);
65
+ const [drawerOpened, setDrawerOpened] = useState(false);
66
+ const {
67
+ drawerPosition = defaultProps.drawerPosition,
68
+ drawerWidth = defaultProps.drawerWidth,
69
+ drawerType = defaultProps.drawerType,
70
+ drawerBackgroundColor,
71
+ drawerContainerStyle,
72
+ contentContainerStyle,
73
+ minSwipeDistance = defaultProps.minSwipeDistance,
74
+ edgeWidth = defaultProps.edgeWidth,
75
+ drawerLockMode = defaultProps.drawerLockMode,
76
+ overlayColor = defaultProps.overlayColor,
77
+ enableTrackpadTwoFingerGesture = defaultProps.enableTrackpadTwoFingerGesture,
78
+ activeCursor = defaultProps.activeCursor,
79
+ mouseButton = defaultProps.mouseButton,
80
+ statusBarAnimation = defaultProps.statusBarAnimation,
81
+ hideStatusBar,
82
+ keyboardDismissMode,
83
+ userSelect,
84
+ enableContextMenu,
85
+ renderNavigationView,
86
+ onDrawerSlide,
87
+ onDrawerClose,
88
+ onDrawerOpen,
89
+ onDrawerStateChanged
90
+ } = props;
91
+ const isFromLeft = drawerPosition === DrawerPosition.LEFT;
92
+ const sideCorrection = isFromLeft ? 1 : -1; // While closing the drawer when user starts gesture in the greyed out part of the window,
93
+ // we want the drawer to follow only once the finger reaches the edge of the drawer.
94
+ // See the diagram for reference. * = starting finger position, < = current finger position
95
+ // 1) +---------------+ 2) +---------------+ 3) +---------------+ 4) +---------------+
96
+ // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
97
+ // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
98
+ // |XXXXXXXX|..<*..| |XXXXXXXX|.<-*..| |XXXXXXXX|<--*..| |XXXXX|<-----*..|
99
+ // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
100
+ // |XXXXXXXX|......| |XXXXXXXX|......| |XXXXXXXX|......| |XXXXX|.........|
101
+ // +---------------+ +---------------+ +---------------+ +---------------+
102
+
103
+ const openValue = useSharedValue(0);
104
+ useDerivedValue(() => {
105
+ onDrawerSlide && runOnJS(onDrawerSlide)(openValue.value);
106
+ }, []);
107
+ const isDrawerOpen = useSharedValue(false);
108
+
109
+ const handleContainerLayout = ({
110
+ nativeEvent
111
+ }) => {
112
+ setContainerWidth(nativeEvent.layout.width);
113
+ };
114
+
115
+ const emitStateChanged = useCallback((newState, drawerWillShow) => {
116
+ 'worklet';
117
+
118
+ var _runOnJS;
119
+
120
+ onDrawerStateChanged && ((_runOnJS = runOnJS(onDrawerStateChanged)) === null || _runOnJS === void 0 ? void 0 : _runOnJS(newState, drawerWillShow));
121
+ }, [onDrawerStateChanged]);
122
+ const drawerAnimatedProps = useAnimatedProps(() => ({
123
+ accessibilityViewIsModal: isDrawerOpen.value
124
+ }));
125
+ const overlayAnimatedProps = useAnimatedProps(() => ({
126
+ pointerEvents: isDrawerOpen.value ? 'auto' : 'none'
127
+ })); // While the drawer is hidden, it's hitSlop overflows onto the main view by edgeWidth
128
+ // This way it can be swiped open even when it's hidden
129
+
130
+ const [edgeHitSlop, setEdgeHitSlop] = useState(isFromLeft ? {
131
+ left: 0,
132
+ width: edgeWidth
133
+ } : {
134
+ right: 0,
135
+ width: edgeWidth
136
+ }); // gestureOrientation is 1 if the gesture is expected to move from left to right and -1 otherwise
137
+
138
+ const gestureOrientation = useMemo(() => sideCorrection * (drawerOpened ? -1 : 1), [sideCorrection, drawerOpened]);
139
+ useEffect(() => {
140
+ setEdgeHitSlop(isFromLeft ? {
141
+ left: 0,
142
+ width: edgeWidth
143
+ } : {
144
+ right: 0,
145
+ width: edgeWidth
146
+ });
147
+ }, [isFromLeft, edgeWidth]);
148
+ const animateDrawer = useCallback((toValue, initialVelocity, animationSpeed) => {
149
+ 'worklet';
150
+
151
+ const willShow = toValue !== 0;
152
+ isDrawerOpen.value = willShow;
153
+ emitStateChanged(DrawerState.SETTLING, willShow);
154
+ runOnJS(setDrawerState)(DrawerState.SETTLING);
155
+
156
+ if (hideStatusBar) {
157
+ runOnJS(StatusBar.setHidden)(willShow, statusBarAnimation);
158
+ }
159
+
160
+ const normalizedToValue = interpolate(toValue, [0, drawerWidth], [0, 1], Extrapolation.CLAMP);
161
+ const normalizedInitialVelocity = interpolate(initialVelocity, [0, drawerWidth], [0, 1], Extrapolation.CLAMP);
162
+ openValue.value = withSpring(normalizedToValue, {
163
+ overshootClamping: true,
164
+ velocity: normalizedInitialVelocity,
165
+ mass: animationSpeed ? 1 / animationSpeed : 1,
166
+ damping: 40,
167
+ stiffness: 500
168
+ }, finished => {
169
+ if (finished) {
170
+ emitStateChanged(DrawerState.IDLE, willShow);
171
+ runOnJS(setDrawerOpened)(willShow);
172
+ runOnJS(setDrawerState)(DrawerState.IDLE);
173
+
174
+ if (willShow) {
175
+ var _runOnJS2;
176
+
177
+ onDrawerOpen && ((_runOnJS2 = runOnJS(onDrawerOpen)) === null || _runOnJS2 === void 0 ? void 0 : _runOnJS2());
178
+ } else {
179
+ var _runOnJS3;
180
+
181
+ onDrawerClose && ((_runOnJS3 = runOnJS(onDrawerClose)) === null || _runOnJS3 === void 0 ? void 0 : _runOnJS3());
182
+ }
183
+ }
184
+ });
185
+ }, [openValue, emitStateChanged, isDrawerOpen, hideStatusBar, onDrawerClose, onDrawerOpen, drawerWidth, statusBarAnimation]);
186
+ const handleRelease = useCallback(event => {
187
+ 'worklet';
188
+
189
+ let {
190
+ translationX: dragX,
191
+ velocityX,
192
+ x: touchX
193
+ } = event;
194
+
195
+ if (drawerPosition !== DrawerPosition.LEFT) {
196
+ // See description in _updateAnimatedEvent about why events are flipped
197
+ // for right-side drawer
198
+ dragX = -dragX;
199
+ touchX = containerWidth - touchX;
200
+ velocityX = -velocityX;
201
+ }
202
+
203
+ const gestureStartX = touchX - dragX;
204
+ let dragOffsetBasedOnStart = 0;
205
+
206
+ if (drawerType === DrawerType.FRONT) {
207
+ dragOffsetBasedOnStart = gestureStartX > drawerWidth ? gestureStartX - drawerWidth : 0;
208
+ }
209
+
210
+ const startOffsetX = dragX + dragOffsetBasedOnStart + (isDrawerOpen.value ? drawerWidth : 0);
211
+ const projOffsetX = startOffsetX + DRAG_TOSS * velocityX;
212
+ const shouldOpen = projOffsetX > drawerWidth / 2;
213
+
214
+ if (shouldOpen) {
215
+ animateDrawer(drawerWidth, velocityX);
216
+ } else {
217
+ animateDrawer(0, velocityX);
218
+ }
219
+ }, [animateDrawer, containerWidth, drawerPosition, drawerType, drawerWidth, isDrawerOpen]);
220
+ const openDrawer = useCallback((options = {}) => {
221
+ 'worklet';
222
+
223
+ var _options$initialVeloc;
224
+
225
+ animateDrawer(drawerWidth, (_options$initialVeloc = options.initialVelocity) !== null && _options$initialVeloc !== void 0 ? _options$initialVeloc : 0, options.animationSpeed);
226
+ }, [animateDrawer, drawerWidth]);
227
+ const closeDrawer = useCallback((options = {}) => {
228
+ 'worklet';
229
+
230
+ var _options$initialVeloc2;
231
+
232
+ animateDrawer(0, (_options$initialVeloc2 = options.initialVelocity) !== null && _options$initialVeloc2 !== void 0 ? _options$initialVeloc2 : 0, options.animationSpeed);
233
+ }, [animateDrawer]);
234
+ const overlayDismissGesture = useMemo(() => Gesture.Tap().maxDistance(25).onEnd(() => {
235
+ if (isDrawerOpen.value && drawerLockMode !== DrawerLockMode.LOCKED_OPEN) {
236
+ closeDrawer();
237
+ }
238
+ }), [closeDrawer, isDrawerOpen, drawerLockMode]);
239
+ const overlayAnimatedStyle = useAnimatedStyle(() => ({
240
+ opacity: openValue.value,
241
+ backgroundColor: overlayColor
242
+ }));
243
+ const fillHitSlop = useMemo(() => isFromLeft ? {
244
+ left: drawerWidth
245
+ } : {
246
+ right: drawerWidth
247
+ }, [drawerWidth, isFromLeft]);
248
+ const panGesture = useMemo(() => {
249
+ return Gesture.Pan().activeCursor(activeCursor).mouseButton(mouseButton).hitSlop(drawerOpened ? fillHitSlop : edgeHitSlop).minDistance(drawerOpened ? 100 : 0).activeOffsetX(gestureOrientation * minSwipeDistance).failOffsetY([-15, 15]).simultaneousWithExternalGesture(overlayDismissGesture).enableTrackpadTwoFingerGesture(enableTrackpadTwoFingerGesture).enabled(drawerState !== DrawerState.SETTLING && (drawerOpened ? drawerLockMode !== DrawerLockMode.LOCKED_OPEN : drawerLockMode !== DrawerLockMode.LOCKED_CLOSED)).onStart(() => {
250
+ emitStateChanged(DrawerState.DRAGGING, false);
251
+ runOnJS(setDrawerState)(DrawerState.DRAGGING);
252
+
253
+ if (keyboardDismissMode === DrawerKeyboardDismissMode.ON_DRAG) {
254
+ runOnJS(Keyboard.dismiss)();
255
+ }
256
+
257
+ if (hideStatusBar) {
258
+ runOnJS(StatusBar.setHidden)(true, statusBarAnimation);
259
+ }
260
+ }).onUpdate(event => {
261
+ const startedOutsideTranslation = isFromLeft ? interpolate(event.x, [0, drawerWidth, drawerWidth + 1], [0, drawerWidth, drawerWidth]) : interpolate(event.x - containerWidth, [-drawerWidth - 1, -drawerWidth, 0], [drawerWidth, drawerWidth, 0]);
262
+ const startedInsideTranslation = sideCorrection * (event.translationX + (drawerOpened ? drawerWidth * -gestureOrientation : 0));
263
+ const adjustedTranslation = Math.max(drawerOpened ? startedOutsideTranslation : 0, startedInsideTranslation);
264
+ openValue.value = interpolate(adjustedTranslation, [-drawerWidth, 0, drawerWidth], [1, 0, 1], Extrapolation.CLAMP);
265
+ }).onEnd(handleRelease);
266
+ }, [drawerLockMode, openValue, drawerWidth, emitStateChanged, gestureOrientation, handleRelease, edgeHitSlop, fillHitSlop, minSwipeDistance, hideStatusBar, keyboardDismissMode, overlayDismissGesture, drawerOpened, isFromLeft, containerWidth, sideCorrection, drawerState, activeCursor, enableTrackpadTwoFingerGesture, mouseButton, statusBarAnimation]); // When using RTL, row and row-reverse flex directions are flipped.
267
+
268
+ const reverseContentDirection = I18nManager.isRTL ? isFromLeft : !isFromLeft;
269
+ const dynamicDrawerStyles = {
270
+ backgroundColor: drawerBackgroundColor,
271
+ width: drawerWidth
272
+ };
273
+ const containerStyles = useAnimatedStyle(() => {
274
+ if (drawerType === DrawerType.FRONT) {
275
+ return {};
276
+ }
277
+
278
+ return {
279
+ transform: [{
280
+ translateX: interpolate(openValue.value, [0, 1], [0, drawerWidth * sideCorrection], Extrapolation.CLAMP)
281
+ }]
282
+ };
283
+ });
284
+ const drawerAnimatedStyle = useAnimatedStyle(() => {
285
+ const closedDrawerOffset = drawerWidth * -sideCorrection;
286
+ const isBack = drawerType === DrawerType.BACK;
287
+ const isIdle = drawerState === DrawerState.IDLE;
288
+
289
+ if (isBack) {
290
+ return {
291
+ transform: [{
292
+ translateX: 0
293
+ }],
294
+ flexDirection: reverseContentDirection ? 'row-reverse' : 'row'
295
+ };
296
+ }
297
+
298
+ let translateX = 0;
299
+
300
+ if (isIdle) {
301
+ translateX = drawerOpened ? 0 : closedDrawerOffset;
302
+ } else {
303
+ translateX = interpolate(openValue.value, [0, 1], [closedDrawerOffset, 0], Extrapolation.CLAMP);
304
+ }
305
+
306
+ return {
307
+ transform: [{
308
+ translateX
309
+ }],
310
+ flexDirection: reverseContentDirection ? 'row-reverse' : 'row'
311
+ };
312
+ });
313
+ const containerAnimatedProps = useAnimatedProps(() => ({
314
+ importantForAccessibility: Platform.OS === 'android' ? isDrawerOpen.value ? 'no-hide-descendants' : 'yes' : undefined
315
+ }));
316
+ const children = typeof props.children === 'function' ? props.children(openValue) // renderer function
317
+ : props.children;
318
+ useImperativeHandle(ref, () => ({
319
+ openDrawer,
320
+ closeDrawer
321
+ }), [openDrawer, closeDrawer]);
322
+ return /*#__PURE__*/React.createElement(GestureDetector, {
323
+ gesture: panGesture,
324
+ userSelect: userSelect,
325
+ enableContextMenu: enableContextMenu
326
+ }, /*#__PURE__*/React.createElement(Animated.View, {
327
+ style: styles.main,
328
+ onLayout: handleContainerLayout
329
+ }, /*#__PURE__*/React.createElement(GestureDetector, {
330
+ gesture: overlayDismissGesture
331
+ }, /*#__PURE__*/React.createElement(Animated.View, {
332
+ style: [drawerType === DrawerType.FRONT ? styles.containerOnBack : styles.containerInFront, containerStyles, contentContainerStyle],
333
+ animatedProps: containerAnimatedProps
334
+ }, children, /*#__PURE__*/React.createElement(Animated.View, {
335
+ animatedProps: overlayAnimatedProps,
336
+ style: [styles.overlay, overlayAnimatedStyle]
337
+ }))), /*#__PURE__*/React.createElement(Animated.View, {
338
+ pointerEvents: "box-none",
339
+ animatedProps: drawerAnimatedProps,
340
+ style: [styles.drawerContainer, drawerAnimatedStyle, drawerContainerStyle]
341
+ }, /*#__PURE__*/React.createElement(Animated.View, {
342
+ style: dynamicDrawerStyles
343
+ }, renderNavigationView(openValue)))));
344
+ });
345
+ export default DrawerLayout;
346
+ const styles = StyleSheet.create({
347
+ drawerContainer: { ...StyleSheet.absoluteFillObject,
348
+ zIndex: 1001,
349
+ flexDirection: 'row'
350
+ },
351
+ containerInFront: { ...StyleSheet.absoluteFillObject,
352
+ zIndex: 1002
353
+ },
354
+ containerOnBack: { ...StyleSheet.absoluteFillObject
355
+ },
356
+ main: {
357
+ flex: 1,
358
+ zIndex: 0,
359
+ overflow: 'hidden'
360
+ },
361
+ overlay: { ...StyleSheet.absoluteFillObject,
362
+ zIndex: 1000
363
+ }
364
+ });
365
+ //# sourceMappingURL=ReanimatedDrawerLayout.js.map