From 7768b622633bf41d01415a878d24f1914f95d0c1 Mon Sep 17 00:00:00 2001 From: Harvey Appleton Date: Wed, 18 Dec 2024 14:46:49 +0000 Subject: [PATCH] Fix glitch when reordering Based on this patch: https://github.com/computerjazz/react-native-draggable-flatlist/issues/561#issuecomment-2511831441 --- lib/commonjs/components/CellDecorators.js | 8 ++--- lib/commonjs/components/CellDecorators.js.map | 2 +- .../components/CellRendererComponent.js | 34 +++++++------------ .../components/CellRendererComponent.js.map | 2 +- lib/commonjs/components/DraggableFlatList.js | 26 +++++++------- .../components/DraggableFlatList.js.map | 2 +- .../components/NestableDraggableFlatList.js | 4 +-- .../NestableDraggableFlatList.js.map | 2 +- .../components/NestableScrollContainer.js | 4 +-- .../components/NestableScrollContainer.js.map | 2 +- lib/commonjs/components/PlaceholderItem.js | 8 ++--- .../components/PlaceholderItem.js.map | 2 +- lib/commonjs/components/RowItem.js | 6 ++-- lib/commonjs/components/RowItem.js.map | 2 +- .../components/ScrollOffsetListener.js | 4 +-- .../components/ScrollOffsetListener.js.map | 2 +- lib/commonjs/context/animatedValueContext.js | 20 +++++------ .../context/animatedValueContext.js.map | 2 +- lib/commonjs/context/cellContext.js | 2 +- lib/commonjs/context/cellContext.js.map | 2 +- .../context/draggableFlatListContext.js | 2 +- .../context/draggableFlatListContext.js.map | 2 +- .../context/nestableScrollContainerContext.js | 2 +- .../nestableScrollContainerContext.js.map | 2 +- lib/commonjs/context/propsContext.js | 2 +- lib/commonjs/context/propsContext.js.map | 2 +- lib/commonjs/context/refContext.js | 2 +- lib/commonjs/context/refContext.js.map | 2 +- lib/commonjs/hooks/useAutoScroll.js | 24 ++++++------- lib/commonjs/hooks/useAutoScroll.js.map | 2 +- lib/commonjs/hooks/useCellTranslate.js | 2 +- lib/commonjs/hooks/useCellTranslate.js.map | 2 +- lib/commonjs/hooks/useNestedAutoScroll.js | 20 +++++------ lib/commonjs/hooks/useNestedAutoScroll.js.map | 2 +- .../hooks/useOnCellActiveAnimation.js | 2 +- .../hooks/useOnCellActiveAnimation.js.map | 2 +- .../components/CellRendererComponent.js | 25 +++----------- .../components/CellRendererComponent.js.map | 2 +- package.json | 2 +- src/components/CellRendererComponent.tsx | 17 ++-------- 40 files changed, 110 insertions(+), 144 deletions(-) diff --git a/lib/commonjs/components/CellDecorators.js b/lib/commonjs/components/CellDecorators.js index d23e3e95..14292cad 100644 --- a/lib/commonjs/components/CellDecorators.js +++ b/lib/commonjs/components/CellDecorators.js @@ -16,7 +16,7 @@ var _draggableFlatListContext = require("../context/draggableFlatListContext"); var _useOnCellActiveAnimation = require("../hooks/useOnCellActiveAnimation"); var _this = this, _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellDecorators.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellDecorators.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); @@ -93,7 +93,7 @@ var ScaleDecorator = function ScaleDecorator(_ref) { "function _f(){const{interpolate,onActiveAnim,activeScale,isActive}=jsThis._closure;{const animScale=interpolate(onActiveAnim.value,[0,1],[1,activeScale]);const scale=isActive?animScale:1;return{transform:[{scaleX:scale},{scaleY:scale}]};}}"; _f.__workletHash = 17199828062713; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellDecorators.tsx (22:33)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellDecorators.tsx (22:33)"; _f.__optimalization = 3; return _f; })(), @@ -150,7 +150,7 @@ var ShadowDecorator = function ShadowDecorator(_ref2) { 'function _f(){const{onActiveAnim,opacity,isActive,elevation,radius,color}=jsThis._closure;{const shadowOpacity=onActiveAnim.value*opacity;return{elevation:isActive?elevation:0,shadowRadius:isActive?radius:0,shadowColor:isActive?color:"transparent",shadowOpacity:isActive?shadowOpacity:0};}}'; _f.__workletHash = 4043081223969; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellDecorators.tsx (55:33)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellDecorators.tsx (55:33)"; _f.__optimalization = 3; return _f; })(), @@ -198,7 +198,7 @@ var OpacityDecorator = function OpacityDecorator(_ref3) { "function _f(){const{interpolate,onActiveAnim,activeOpacity,isActive}=jsThis._closure;{const opacity=interpolate(onActiveAnim.value,[0,1],[1,activeOpacity]);return{opacity:isActive?opacity:1};}}"; _f.__workletHash = 11305163295580; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellDecorators.tsx (83:33)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellDecorators.tsx (83:33)"; _f.__optimalization = 3; return _f; })(), diff --git a/lib/commonjs/components/CellDecorators.js.map b/lib/commonjs/components/CellDecorators.js.map index d672958a..1093cb61 100644 --- a/lib/commonjs/components/CellDecorators.js.map +++ b/lib/commonjs/components/CellDecorators.js.map @@ -1 +1 @@ -{"version":3,"names":["ScaleDecorator","activeScale","children","useOnCellActiveAnimation","animationConfig","mass","restDisplacementThreshold","isActive","onActiveAnim","useDraggableFlatListContext","horizontal","style","useAnimatedStyle","animScale","interpolate","value","scale","transform","scaleX","scaleY","styles","ShadowDecorator","elevation","color","opacity","radius","shadowOpacity","shadowRadius","shadowColor","OpacityDecorator","activeOpacity","StyleSheet","create","flexDirection","flex"],"sources":["CellDecorators.tsx"],"sourcesContent":["import React from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport Animated, {\n interpolate,\n useAnimatedStyle,\n} from \"react-native-reanimated\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nexport { useOnCellActiveAnimation } from \"../hooks/useOnCellActiveAnimation\";\nimport { useOnCellActiveAnimation } from \"../hooks/useOnCellActiveAnimation\";\n\ntype ScaleProps = {\n activeScale?: number;\n children: React.ReactNode;\n};\n\nexport const ScaleDecorator = ({ activeScale = 1.1, children }: ScaleProps) => {\n const { isActive, onActiveAnim } = useOnCellActiveAnimation({\n animationConfig: { mass: 0.1, restDisplacementThreshold: 0.0001 },\n });\n const { horizontal } = useDraggableFlatListContext();\n\n const style = useAnimatedStyle(() => {\n const animScale = interpolate(onActiveAnim.value, [0, 1], [1, activeScale]);\n const scale = isActive ? animScale : 1;\n return {\n transform: [{ scaleX: scale }, { scaleY: scale }],\n };\n }, [isActive]);\n\n return (\n \n {children}\n \n );\n};\n\ntype ShadowProps = {\n children: React.ReactNode;\n elevation?: number;\n radius?: number;\n color?: string;\n opacity?: number;\n};\n\nexport const ShadowDecorator = ({\n elevation = 10,\n color = \"black\",\n opacity = 0.25,\n radius = 5,\n children,\n}: ShadowProps) => {\n const { isActive, onActiveAnim } = useOnCellActiveAnimation();\n const { horizontal } = useDraggableFlatListContext();\n\n const style = useAnimatedStyle(() => {\n const shadowOpacity = onActiveAnim.value * opacity;\n return {\n elevation: isActive ? elevation : 0,\n shadowRadius: isActive ? radius : 0,\n shadowColor: isActive ? color : \"transparent\",\n shadowOpacity: isActive ? shadowOpacity : 0,\n };\n }, [isActive, onActiveAnim]);\n\n return (\n \n {children}\n \n );\n};\n\ntype OpacityProps = {\n activeOpacity?: number;\n children: React.ReactNode;\n};\n\nexport const OpacityDecorator = ({\n activeOpacity = 0.25,\n children,\n}: OpacityProps) => {\n const { isActive, onActiveAnim } = useOnCellActiveAnimation();\n const { horizontal } = useDraggableFlatListContext();\n const style = useAnimatedStyle(() => {\n const opacity = interpolate(onActiveAnim.value, [0, 1], [1, activeOpacity]);\n return {\n opacity: isActive ? opacity : 1,\n };\n }, [isActive]);\n\n return (\n \n {children}\n \n );\n};\n\nconst styles = StyleSheet.create({\n horizontal: {\n flexDirection: \"row\",\n flex: 1,\n },\n});\n"],"mappings":"sXAAA,oDACA,yCACA,uFAIA,6EACA,2E,ymCAQO,GAAMA,eAAc,CAAG,QAAjBA,eAAiB,MAAiD,2BAA9CC,WAA8C,CAA9CA,WAA8C,2BAAhC,GAAgC,kBAA3BC,QAA2B,MAA3BA,QAA2B,2BAC1C,GAAAC,kDAAA,EAA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,YAgFd,eAhF8CsB,aAgF9C,UA9EHvB,QA8EG,+XAKX,CAACA,QAAD,CALW,CAAd,CAOA,MACE,8BAAC,8BAAD,CAAU,IAAV,EAAe,KAAK,CAAE,CAACI,KAAD,CAAQD,UAAU,EAAIU,MAAM,CAACV,UAA7B,CAAtB,6EACGR,QADH,CADF,CAKD,CAlBM,C,0CAoBP,GAAMkB,OAAM,CAAGW,uBAAA,CAAWC,MAAX,CAAkB,CAC/BtB,UAAU,CAAE,CACVuB,aAAa,CAAE,KADL,CAEVC,IAAI,CAAE,CAFI,CADmB,CAAlB,CAAf"} \ No newline at end of file +{"version":3,"names":["ScaleDecorator","activeScale","children","useOnCellActiveAnimation","animationConfig","mass","restDisplacementThreshold","isActive","onActiveAnim","useDraggableFlatListContext","horizontal","style","useAnimatedStyle","animScale","interpolate","value","scale","transform","scaleX","scaleY","styles","ShadowDecorator","elevation","color","opacity","radius","shadowOpacity","shadowRadius","shadowColor","OpacityDecorator","activeOpacity","StyleSheet","create","flexDirection","flex"],"sources":["CellDecorators.tsx"],"sourcesContent":["import React from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport Animated, {\n interpolate,\n useAnimatedStyle,\n} from \"react-native-reanimated\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nexport { useOnCellActiveAnimation } from \"../hooks/useOnCellActiveAnimation\";\nimport { useOnCellActiveAnimation } from \"../hooks/useOnCellActiveAnimation\";\n\ntype ScaleProps = {\n activeScale?: number;\n children: React.ReactNode;\n};\n\nexport const ScaleDecorator = ({ activeScale = 1.1, children }: ScaleProps) => {\n const { isActive, onActiveAnim } = useOnCellActiveAnimation({\n animationConfig: { mass: 0.1, restDisplacementThreshold: 0.0001 },\n });\n const { horizontal } = useDraggableFlatListContext();\n\n const style = useAnimatedStyle(() => {\n const animScale = interpolate(onActiveAnim.value, [0, 1], [1, activeScale]);\n const scale = isActive ? animScale : 1;\n return {\n transform: [{ scaleX: scale }, { scaleY: scale }],\n };\n }, [isActive]);\n\n return (\n \n {children}\n \n );\n};\n\ntype ShadowProps = {\n children: React.ReactNode;\n elevation?: number;\n radius?: number;\n color?: string;\n opacity?: number;\n};\n\nexport const ShadowDecorator = ({\n elevation = 10,\n color = \"black\",\n opacity = 0.25,\n radius = 5,\n children,\n}: ShadowProps) => {\n const { isActive, onActiveAnim } = useOnCellActiveAnimation();\n const { horizontal } = useDraggableFlatListContext();\n\n const style = useAnimatedStyle(() => {\n const shadowOpacity = onActiveAnim.value * opacity;\n return {\n elevation: isActive ? elevation : 0,\n shadowRadius: isActive ? radius : 0,\n shadowColor: isActive ? color : \"transparent\",\n shadowOpacity: isActive ? shadowOpacity : 0,\n };\n }, [isActive, onActiveAnim]);\n\n return (\n \n {children}\n \n );\n};\n\ntype OpacityProps = {\n activeOpacity?: number;\n children: React.ReactNode;\n};\n\nexport const OpacityDecorator = ({\n activeOpacity = 0.25,\n children,\n}: OpacityProps) => {\n const { isActive, onActiveAnim } = useOnCellActiveAnimation();\n const { horizontal } = useDraggableFlatListContext();\n const style = useAnimatedStyle(() => {\n const opacity = interpolate(onActiveAnim.value, [0, 1], [1, activeOpacity]);\n return {\n opacity: isActive ? opacity : 1,\n };\n }, [isActive]);\n\n return (\n \n {children}\n \n );\n};\n\nconst styles = StyleSheet.create({\n horizontal: {\n flexDirection: \"row\",\n flex: 1,\n },\n});\n"],"mappings":"sXAAA,oDACA,yCACA,uFAIA,6EACA,2E,unCAQO,GAAMA,eAAc,CAAG,QAAjBA,eAAiB,MAAiD,2BAA9CC,WAA8C,CAA9CA,WAA8C,2BAAhC,GAAgC,kBAA3BC,QAA2B,MAA3BA,QAA2B,2BAC1C,GAAAC,kDAAA,EAAyB,CAC1DC,eAAe,CAAE,CAAEC,IAAI,CAAE,GAAR,CAAaC,yBAAyB,CAAE,MAAxC,CADyC,CAAzB,CAD0C,CACrEC,QADqE,uBACrEA,QADqE,CAC3DC,YAD2D,uBAC3DA,YAD2D,2BAItD,GAAAC,qDAAA,GAJsD,CAI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ACGR,QADH,CADF,CAKD,CAlBM,C,0CAoBP,GAAMkB,OAAM,CAAGW,uBAAA,CAAWC,MAAX,CAAkB,CAC/BtB,UAAU,CAAE,CACVuB,aAAa,CAAE,KADL,CAEVC,IAAI,CAAE,CAFI,CADmB,CAAlB,CAAf"} \ No newline at end of file diff --git a/lib/commonjs/components/CellRendererComponent.js b/lib/commonjs/components/CellRendererComponent.js index 965e8867..a5ba0146 100644 --- a/lib/commonjs/components/CellRendererComponent.js +++ b/lib/commonjs/components/CellRendererComponent.js @@ -21,7 +21,7 @@ var _animatedValueContext = require("../context/animatedValueContext"); var _cellContext = _interopRequireDefault(require("../context/cellContext")); var _useStableCallback = require("../hooks/useStableCallback"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); @@ -105,7 +105,7 @@ function CellRendererComponent(props) { if (translate.value && !_constants.isWeb) { heldTanslate.value = translate.value; } - var t = activeKey ? translate.value : heldTanslate.value; + var t = _constants.isWeb ? translate.value : heldTanslate.value; return { transform: [ horizontalAnim.value ? { translateX: t } : { translateY: t }, @@ -116,14 +116,13 @@ function CellRendererComponent(props) { translate: translate, isWeb: _constants.isWeb, heldTanslate: heldTanslate, - activeKey: activeKey, horizontalAnim: horizontalAnim, }; _f.asString = - "function _f(){const{translate,isWeb,heldTanslate,activeKey,horizontalAnim}=jsThis._closure;{if(translate.value&&!isWeb){heldTanslate.value=translate.value;}const t=activeKey?translate.value:heldTanslate.value;return{transform:[horizontalAnim.value?{translateX:t}:{translateY:t}]};}}"; - _f.__workletHash = 2668800953096; + "function _f(){const{translate,isWeb,heldTanslate,horizontalAnim}=jsThis._closure;{if(translate.value&&!isWeb){heldTanslate.value=translate.value;}const t=isWeb?translate.value:heldTanslate.value;return{transform:[horizontalAnim.value?{translateX:t}:{translateY:t}]};}}"; + _f.__workletHash = 12099388212558; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (59:37)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (58:37)"; _f.__optimalization = 1; return _f; })(), @@ -159,12 +158,12 @@ function CellRendererComponent(props) { } ); var onCellLayout = (0, _useStableCallback.useStableCallback)(function (e) { - heldTanslate.value = 0; updateCellMeasurements(); if (onLayout && e) onLayout(e); }); (0, _react.useEffect)( function () { + heldTanslate.value = 0; if (_constants.isWeb) { requestAnimationFrame(function () { onCellLayout(); @@ -212,7 +211,7 @@ function CellRendererComponent(props) { "function _f(t,_layoutDisabled){const{stashConfig,getStashedConfig}=jsThis._closure;{if(!t)return;const config=global.LayoutAnimationRepository.configs[t];if(config)stashConfig(t,config);const stashedConfig=getStashedConfig(t);if(_layoutDisabled){global.LayoutAnimationRepository.removeConfig(t);}else if(stashedConfig){global.LayoutAnimationRepository.registerConfig(t,stashedConfig);}}}"; _f.__workletHash = 14167513442446; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (140:12)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (139:12)"; return _f; })() )(tag, layoutAnimationDisabled); @@ -229,21 +228,17 @@ function CellRendererComponent(props) { layout: propsRef.current.enableLayoutAnimationExperimental ? itemLayoutAnimation : undefined, - style: [ - props.style, - baseStyle, - activeKey ? animStyle : styles.zeroTranslate, - ], + style: [props.style, baseStyle, animStyle], pointerEvents: activeKey ? "none" : "auto", __self: this, - __source: { fileName: _jsxFileName, lineNumber: 155, columnNumber: 5 }, + __source: { fileName: _jsxFileName, lineNumber: 154, columnNumber: 5 }, }), _react.default.createElement( _cellContext.default, { isActive: isActive, __self: this, - __source: { fileName: _jsxFileName, lineNumber: 173, columnNumber: 7 }, + __source: { fileName: _jsxFileName, lineNumber: 172, columnNumber: 7 }, }, children ) @@ -251,9 +246,6 @@ function CellRendererComponent(props) { } var _default = (0, _utils.typedMemo)(CellRendererComponent); exports.default = _default; -var styles = _reactNative.StyleSheet.create({ - zeroTranslate: { transform: [{ translateX: 0 }, { translateY: 0 }] }, -}); (0, _reactNativeReanimated.runOnUI)( (function () { var _f = function _f() { @@ -263,7 +255,7 @@ var styles = _reactNative.StyleSheet.create({ _f.asString = "function _f(){global.RNDFLLayoutAnimationConfigStash={};}"; _f.__workletHash = 11308490141335; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (194:8)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (187:8)"; return _f; })() )(); @@ -278,7 +270,7 @@ var stashConfig = (function () { "function stashConfig(tag,config){if(!global.RNDFLLayoutAnimationConfigStash)global.RNDFLLayoutAnimationConfigStash={};global.RNDFLLayoutAnimationConfigStash[tag]=config;}"; _f.__workletHash = 481659566906; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (199:0)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (192:0)"; return _f; })(); var getStashedConfig = (function () { @@ -291,7 +283,7 @@ var getStashedConfig = (function () { "function getStashedConfig(tag){if(!global.RNDFLLayoutAnimationConfigStash)return null;return global.RNDFLLayoutAnimationConfigStash[tag];}"; _f.__workletHash = 4781167627856; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (206:0)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/CellRendererComponent.tsx (199:0)"; return _f; })(); //# sourceMappingURL=CellRendererComponent.js.map diff --git a/lib/commonjs/components/CellRendererComponent.js.map b/lib/commonjs/components/CellRendererComponent.js.map index f94d5db1..f9b911c7 100644 --- a/lib/commonjs/components/CellRendererComponent.js.map +++ b/lib/commonjs/components/CellRendererComponent.js.map @@ -1 +1 @@ -{"version":3,"names":["CellRendererComponent","props","item","index","onLayout","children","rest","viewRef","useRef","useRefs","cellDataRef","propsRef","containerRef","useAnimatedValues","horizontalAnim","scrollOffset","useDraggableFlatListContext","activeKey","keyExtractor","horizontal","layoutAnimationDisabled","key","offset","useSharedValue","size","heldTanslate","translate","useCellTranslate","cellOffset","cellSize","cellIndex","isActive","animStyle","useAnimatedStyle","value","isWeb","t","transform","translateX","translateY","updateCellMeasurements","useStableCallback","onSuccess","x","y","w","h","current","set","measurements","onFail","debug","console","log","containerNode","viewNode","nodeHandle","measureLayout","onCellLayout","e","useEffect","requestAnimationFrame","baseStyle","useMemo","elevation","zIndex","flexDirection","itemEnteringAnimation","itemExitingAnimation","itemLayoutAnimation","enableLayoutAnimationExperimental","tag","findNodeHandle","runOnUI","_layoutDisabled","config","global","LayoutAnimationRepository","configs","stashConfig","stashedConfig","getStashedConfig","removeConfig","registerConfig","undefined","style","styles","zeroTranslate","typedMemo","StyleSheet","create","RNDFLLayoutAnimationConfigStash"],"sources":["CellRendererComponent.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport {\n findNodeHandle,\n LayoutChangeEvent,\n MeasureLayoutOnSuccessCallback,\n StyleProp,\n StyleSheet,\n ViewStyle,\n} from \"react-native\";\nimport Animated, {\n runOnUI,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { isWeb } from \"../constants\";\nimport { useCellTranslate } from \"../hooks/useCellTranslate\";\nimport { typedMemo } from \"../utils\";\nimport { useRefs } from \"../context/refContext\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport CellProvider from \"../context/cellContext\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\n\ntype Props = {\n item: T;\n index: number;\n children: React.ReactNode;\n onLayout?: (e: LayoutChangeEvent) => void;\n style?: StyleProp;\n};\n\nfunction CellRendererComponent(props: Props) {\n const { item, index, onLayout, children, ...rest } = props;\n\n const viewRef = useRef(null);\n const { cellDataRef, propsRef, containerRef } = useRefs();\n\n const { horizontalAnim, scrollOffset } = useAnimatedValues();\n const {\n activeKey,\n keyExtractor,\n horizontal,\n layoutAnimationDisabled,\n } = useDraggableFlatListContext();\n\n const key = keyExtractor(item, index);\n const offset = useSharedValue(-1);\n const size = useSharedValue(-1);\n const heldTanslate = useSharedValue(0);\n\n const translate = useCellTranslate({\n cellOffset: offset,\n cellSize: size,\n cellIndex: index,\n });\n\n const isActive = activeKey === key;\n\n const animStyle = useAnimatedStyle(() => {\n // When activeKey becomes null at the end of a drag and the list reorders,\n // the animated style may apply before the next paint, causing a flicker.\n // Solution is to hold over the last animated value until the next onLayout.\n // (Not required in web)\n if (translate.value && !isWeb) {\n heldTanslate.value = translate.value;\n }\n const t = activeKey ? translate.value : heldTanslate.value;\n return {\n transform: [horizontalAnim.value ? { translateX: t } : { translateY: t }],\n };\n }, [translate, activeKey]);\n\n const updateCellMeasurements = useStableCallback(() => {\n const onSuccess: MeasureLayoutOnSuccessCallback = (x, y, w, h) => {\n if (isWeb && horizontal) x += scrollOffset.value;\n const cellOffset = horizontal ? x : y;\n const cellSize = horizontal ? w : h;\n cellDataRef.current.set(key, {\n measurements: { size: cellSize, offset: cellOffset },\n });\n\n size.value = cellSize;\n offset.value = cellOffset;\n };\n\n const onFail = () => {\n if (propsRef.current?.debug) {\n console.log(`## on measure fail, index: ${index}`);\n }\n };\n\n const containerNode = containerRef.current;\n const viewNode = viewRef.current;\n const nodeHandle = containerNode;\n\n if (viewNode && nodeHandle) {\n //@ts-ignore\n viewNode.measureLayout(nodeHandle, onSuccess, onFail);\n }\n });\n\n const onCellLayout = useStableCallback((e?: LayoutChangeEvent) => {\n heldTanslate.value = 0;\n updateCellMeasurements();\n if (onLayout && e) onLayout(e);\n });\n\n useEffect(() => {\n if (isWeb) {\n // onLayout isn't called on web when the cell index changes, so we manually re-measure\n requestAnimationFrame(() => {\n onCellLayout();\n });\n }\n }, [index, onCellLayout]);\n\n const baseStyle = useMemo(() => {\n return {\n elevation: isActive ? 1 : 0,\n zIndex: isActive ? 999 : 0,\n flexDirection: horizontal ? (\"row\" as const) : (\"column\" as const),\n };\n }, [isActive, horizontal]);\n\n const {\n itemEnteringAnimation,\n itemExitingAnimation,\n itemLayoutAnimation,\n } = propsRef.current;\n\n useEffect(() => {\n // NOTE: Keep an eye on reanimated LayoutAnimation refactor:\n // https://github.com/software-mansion/react-native-reanimated/pull/3332/files\n // We might have to change the way we register/unregister LayouAnimations:\n // - get native module: https://github.com/software-mansion/react-native-reanimated/blob/cf59766460d05eb30357913455318d8a95909468/src/reanimated2/NativeReanimated/NativeReanimated.ts#L18\n // - register layout animation for tag: https://github.com/software-mansion/react-native-reanimated/blob/cf59766460d05eb30357913455318d8a95909468/src/reanimated2/NativeReanimated/NativeReanimated.ts#L99\n if (!propsRef.current.enableLayoutAnimationExperimental) return;\n const tag = findNodeHandle(viewRef.current);\n\n runOnUI((t: number | null, _layoutDisabled) => {\n \"worklet\";\n if (!t) return;\n const config = global.LayoutAnimationRepository.configs[t];\n if (config) stashConfig(t, config);\n const stashedConfig = getStashedConfig(t);\n if (_layoutDisabled) {\n global.LayoutAnimationRepository.removeConfig(t);\n } else if (stashedConfig) {\n global.LayoutAnimationRepository.registerConfig(t, stashedConfig);\n }\n })(tag, layoutAnimationDisabled);\n }, [layoutAnimationDisabled]);\n\n return (\n \n {children}\n \n );\n}\n\nexport default typedMemo(CellRendererComponent);\n\nconst styles = StyleSheet.create({\n zeroTranslate: {\n transform: [{ translateX: 0 }, { translateY: 0 }],\n },\n});\n\ndeclare global {\n namespace NodeJS {\n interface Global {\n RNDFLLayoutAnimationConfigStash: Record;\n }\n }\n}\n\nrunOnUI(() => {\n \"worklet\";\n global.RNDFLLayoutAnimationConfigStash = {};\n})();\n\nfunction stashConfig(tag: number, config: unknown) {\n \"worklet\";\n if (!global.RNDFLLayoutAnimationConfigStash)\n global.RNDFLLayoutAnimationConfigStash = {};\n global.RNDFLLayoutAnimationConfigStash[tag] = config;\n}\n\nfunction getStashedConfig(tag: number) {\n \"worklet\";\n if (!global.RNDFLLayoutAnimationConfigStash) return null;\n return global.RNDFLLayoutAnimationConfigStash[tag] as Record;\n}\n"],"mappings":"mWAAA,qDACA,yCAQA,uFAKA,6EACA,uCACA,2DACA,+BACA,iDACA,qEACA,2EACA,6D,qmCAUA,QAASA,sBAAT,CAAkCC,KAAlC,CAAmD,IACzCC,KADyC,CACID,KADJ,CACzCC,IADyC,CACnCC,KADmC,CACIF,KADJ,CACnCE,KADmC,CAC5BC,QAD4B,CACIH,KADJ,CAC5BG,QAD4B,CAClBC,QADkB,CACIJ,KADJ,CAClBI,QADkB,CACLC,IADK,uCACIL,KADJ,yCAGjD,GAAMM,QAAO,CAAG,GAAAC,aAAA,EAAsB,IAAtB,CAAhB,CAHiD,aAID,GAAAC,mBAAA,GAJC,CAIzCC,WAJyC,UAIzCA,WAJyC,CAI5BC,QAJ4B,UAI5BA,QAJ4B,CAIlBC,YAJkB,UAIlBA,YAJkB,wBAMR,GAAAC,uCAAA,GANQ,CAMzCC,cANyC,oBAMzCA,cANyC,CAMzBC,YANyB,oBAMzBA,YANyB,2BAY7C,GAAAC,qDAAA,GAZ6C,CAQ/CC,SAR+C,uBAQ/CA,SAR+C,CAS/CC,YAT+C,uBAS/CA,YAT+C,CAU/CC,UAV+C,uBAU/CA,UAV+C,CAW/CC,uBAX+C,uBAW/CA,uBAX+C,CAcjD,GAAMC,IAAG,CAAGH,YAAY,CAAChB,IAAD,CAAOC,KAAP,CAAxB,CACA,GAAMmB,OAAM,CAAG,GAAAC,qCAAA,EAAe,CAAC,CAAhB,CAAf,CACA,GAAMC,KAAI,CAAG,GAAAD,qCAAA,EAAe,CAAC,CAAhB,CAAb,CACA,GAAME,aAAY,CAAG,GAAAF,qCAAA,EAAe,CAAf,CAArB,CAEA,GAAMG,UAAS,CAAG,GAAAC,kCAAA,EAAiB,CACjCC,UAAU,CAAEN,MADqB,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,MAAM,CAACC,aAH1B,CAXT,CAgBE,aAAa,CAAEtE,SAAS,CAAG,MAAH,CAAY,MAhBtC,8EAkBE,6BAAC,oBAAD,EAAc,QAAQ,CAAEc,QAAxB,6EAAmC1B,QAAnC,CAlBF,CADF,CAsBD,C,aAEc,GAAAmF,gBAAA,EAAUxF,qBAAV,C,0BAEf,GAAMsF,OAAM,CAAGG,uBAAA,CAAWC,MAAX,CAAkB,CAC/BH,aAAa,CAAE,CACblD,SAAS,CAAE,CAAC,CAAEC,UAAU,CAAE,CAAd,CAAD,CAAoB,CAAEC,UAAU,CAAE,CAAd,CAApB,CADE,CADgB,CAAlB,CAAf,CAcA,GAAAkC,8BAAA,iCAAc,CAEZG,MAAM,CAACe,+BAAP,CAAyC,EAAzC,CACD,CAHD,yP,GAKSZ,Y,+BAAYR,G,CAAaI,M,CAAiB,CAEjD,GAAI,CAACC,MAAM,CAACe,+BAAZ,CACEf,MAAM,CAACe,+BAAP,CAAyC,EAAzC,CACFf,MAAM,CAACe,+BAAP,CAAuCpB,GAAvC,EAA8CI,MAA9C,CACD,C,wWAEQM,iB,+BAAiBV,G,CAAa,CAErC,GAAI,CAACK,MAAM,CAACe,+BAAZ,CAA6C,MAAO,KAAP,CAC7C,MAAOf,OAAM,CAACe,+BAAP,CAAuCpB,GAAvC,CAAP,CACD,C"} \ No newline at end of file +{"version":3,"names":["CellRendererComponent","props","item","index","onLayout","children","rest","viewRef","useRef","useRefs","cellDataRef","propsRef","containerRef","useAnimatedValues","horizontalAnim","scrollOffset","useDraggableFlatListContext","activeKey","keyExtractor","horizontal","layoutAnimationDisabled","key","offset","useSharedValue","size","heldTanslate","translate","useCellTranslate","cellOffset","cellSize","cellIndex","isActive","animStyle","useAnimatedStyle","value","isWeb","t","transform","translateX","translateY","updateCellMeasurements","useStableCallback","onSuccess","x","y","w","h","current","set","measurements","onFail","debug","console","log","containerNode","viewNode","nodeHandle","measureLayout","onCellLayout","e","useEffect","requestAnimationFrame","baseStyle","useMemo","elevation","zIndex","flexDirection","itemEnteringAnimation","itemExitingAnimation","itemLayoutAnimation","enableLayoutAnimationExperimental","tag","findNodeHandle","runOnUI","_layoutDisabled","config","global","LayoutAnimationRepository","configs","stashConfig","stashedConfig","getStashedConfig","removeConfig","registerConfig","undefined","style","typedMemo","RNDFLLayoutAnimationConfigStash"],"sources":["CellRendererComponent.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport {\n findNodeHandle,\n LayoutChangeEvent,\n MeasureLayoutOnSuccessCallback,\n StyleProp,\n ViewStyle,\n} from \"react-native\";\nimport Animated, {\n runOnUI,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { isWeb } from \"../constants\";\nimport { useCellTranslate } from \"../hooks/useCellTranslate\";\nimport { typedMemo } from \"../utils\";\nimport { useRefs } from \"../context/refContext\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport CellProvider from \"../context/cellContext\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\n\ntype Props = {\n item: T;\n index: number;\n children: React.ReactNode;\n onLayout?: (e: LayoutChangeEvent) => void;\n style?: StyleProp;\n};\n\nfunction CellRendererComponent(props: Props) {\n const { item, index, onLayout, children, ...rest } = props;\n\n const viewRef = useRef(null);\n const { cellDataRef, propsRef, containerRef } = useRefs();\n\n const { horizontalAnim, scrollOffset } = useAnimatedValues();\n const {\n activeKey,\n keyExtractor,\n horizontal,\n layoutAnimationDisabled,\n } = useDraggableFlatListContext();\n\n const key = keyExtractor(item, index);\n const offset = useSharedValue(-1);\n const size = useSharedValue(-1);\n const heldTanslate = useSharedValue(0);\n\n const translate = useCellTranslate({\n cellOffset: offset,\n cellSize: size,\n cellIndex: index,\n });\n\n const isActive = activeKey === key;\n\n const animStyle = useAnimatedStyle(() => {\n // When activeKey becomes null at the end of a drag and the list reorders,\n // the animated style may apply before the next paint, causing a flicker.\n // Solution is to hold over the last animated value until the next onLayout.\n // (Not required in web)\n if (translate.value && !isWeb) {\n heldTanslate.value = translate.value;\n }\n const t = isWeb ? translate.value : heldTanslate.value;\n return {\n transform: [horizontalAnim.value ? { translateX: t } : { translateY: t }],\n };\n }, [translate, activeKey]);\n\n const updateCellMeasurements = useStableCallback(() => {\n const onSuccess: MeasureLayoutOnSuccessCallback = (x, y, w, h) => {\n if (isWeb && horizontal) x += scrollOffset.value;\n const cellOffset = horizontal ? x : y;\n const cellSize = horizontal ? w : h;\n cellDataRef.current.set(key, {\n measurements: { size: cellSize, offset: cellOffset },\n });\n\n size.value = cellSize;\n offset.value = cellOffset;\n };\n\n const onFail = () => {\n if (propsRef.current?.debug) {\n console.log(`## on measure fail, index: ${index}`);\n }\n };\n\n const containerNode = containerRef.current;\n const viewNode = viewRef.current;\n const nodeHandle = containerNode;\n\n if (viewNode && nodeHandle) {\n //@ts-ignore\n viewNode.measureLayout(nodeHandle, onSuccess, onFail);\n }\n });\n\n const onCellLayout = useStableCallback((e?: LayoutChangeEvent) => {\n updateCellMeasurements();\n if (onLayout && e) onLayout(e);\n });\n\n useEffect(() => {\n heldTanslate.value = 0;\n if (isWeb) {\n // onLayout isn't called on web when the cell index changes, so we manually re-measure\n requestAnimationFrame(() => {\n onCellLayout();\n });\n }\n }, [index, onCellLayout]);\n\n const baseStyle = useMemo(() => {\n return {\n elevation: isActive ? 1 : 0,\n zIndex: isActive ? 999 : 0,\n flexDirection: horizontal ? (\"row\" as const) : (\"column\" as const),\n };\n }, [isActive, horizontal]);\n\n const {\n itemEnteringAnimation,\n itemExitingAnimation,\n itemLayoutAnimation,\n } = propsRef.current;\n\n useEffect(() => {\n // NOTE: Keep an eye on reanimated LayoutAnimation refactor:\n // https://github.com/software-mansion/react-native-reanimated/pull/3332/files\n // We might have to change the way we register/unregister LayouAnimations:\n // - get native module: https://github.com/software-mansion/react-native-reanimated/blob/cf59766460d05eb30357913455318d8a95909468/src/reanimated2/NativeReanimated/NativeReanimated.ts#L18\n // - register layout animation for tag: https://github.com/software-mansion/react-native-reanimated/blob/cf59766460d05eb30357913455318d8a95909468/src/reanimated2/NativeReanimated/NativeReanimated.ts#L99\n if (!propsRef.current.enableLayoutAnimationExperimental) return;\n const tag = findNodeHandle(viewRef.current);\n\n runOnUI((t: number | null, _layoutDisabled) => {\n \"worklet\";\n if (!t) return;\n const config = global.LayoutAnimationRepository.configs[t];\n if (config) stashConfig(t, config);\n const stashedConfig = getStashedConfig(t);\n if (_layoutDisabled) {\n global.LayoutAnimationRepository.removeConfig(t);\n } else if (stashedConfig) {\n global.LayoutAnimationRepository.registerConfig(t, stashedConfig);\n }\n })(tag, layoutAnimationDisabled);\n }, [layoutAnimationDisabled]);\n\n return (\n \n {children}\n \n );\n}\n\nexport default typedMemo(CellRendererComponent);\n\ndeclare global {\n namespace NodeJS {\n interface Global {\n RNDFLLayoutAnimationConfigStash: Record;\n }\n }\n}\n\nrunOnUI(() => {\n \"worklet\";\n global.RNDFLLayoutAnimationConfigStash = {};\n})();\n\nfunction stashConfig(tag: number, config: unknown) {\n \"worklet\";\n if (!global.RNDFLLayoutAnimationConfigStash)\n global.RNDFLLayoutAnimationConfigStash = {};\n global.RNDFLLayoutAnimationConfigStash[tag] = config;\n}\n\nfunction getStashedConfig(tag: number) {\n \"worklet\";\n if (!global.RNDFLLayoutAnimationConfigStash) return null;\n return global.RNDFLLayoutAnimationConfigStash[tag] as Record;\n}\n"],"mappings":"mWAAA,qDACA,yCAOA,uFAKA,6EACA,uCACA,2DACA,+BACA,iDACA,qEACA,2EACA,6D,mnCAUA,QAASA,sBAAT,CAAkCC,KAAlC,CAAmD,IACzCC,KADyC,CACID,KADJ,CACzCC,IADyC,CACnCC,KADmC,CACIF,KADJ,CACnCE,KADmC,CAC5BC,QAD4B,CACIH,KADJ,CAC5BG,QAD4B,CAClBC,QADkB,CACIJ,KADJ,CAClBI,QADkB,CACLC,IADK,uCACIL,KADJ,yCAGjD,GAAMM,QAAO,CAAG,GAAAC,aAAA,EAA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AAP,CAC7C,MAAOX,OAAM,CAACW,+BAAP,CAAuChB,GAAvC,CAAP,CACD,C"} \ No newline at end of file diff --git a/lib/commonjs/components/DraggableFlatList.js b/lib/commonjs/components/DraggableFlatList.js index ace1f533..cada4245 100644 --- a/lib/commonjs/components/DraggableFlatList.js +++ b/lib/commonjs/components/DraggableFlatList.js @@ -36,7 +36,7 @@ var _ScrollOffsetListener = _interopRequireDefault( ); var _utils = require("../utils"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); @@ -284,7 +284,7 @@ function DraggableFlatListInner(props) { "function _f(){const{isTouchActiveNative}=jsThis._closure;{return isTouchActiveNative.value;}}"; _f.__workletHash = 14702024657843; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (239:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (239:4)"; return _f; })(), (function () { @@ -315,7 +315,7 @@ function DraggableFlatListInner(props) { "function _f(cur,prev){const{touchTranslate,activeIndexAnim,disabled,runOnJS,onRelease,onDragEnd,spacerIndexAnim}=jsThis._closure;{if(cur!==prev&&!cur){const hasMoved=!!touchTranslate.value;if(!hasMoved&&activeIndexAnim.value>=0&&!disabled.value){runOnJS(onRelease)(activeIndexAnim.value);runOnJS(onDragEnd)({from:activeIndexAnim.value,to:spacerIndexAnim.value});}}}}"; _f.__workletHash = 5951241873481; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (242:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (242:4)"; return _f; })(), [isTouchActiveNative, onDragEnd, onRelease] @@ -330,7 +330,7 @@ function DraggableFlatListInner(props) { "function _f(){const{spacerIndexAnim}=jsThis._closure;{return spacerIndexAnim.value;}}"; _f.__workletHash = 2960108028947; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (258:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (258:4)"; return _f; })(), (function () { @@ -347,7 +347,7 @@ function DraggableFlatListInner(props) { "function _f(cur,prev){const{runOnJS,onPlaceholderIndexChange}=jsThis._closure;{if(prev!==null&&cur!==prev&&cur>=0&&prev>=0){runOnJS(onPlaceholderIndexChange)(cur);}}}"; _f.__workletHash = 16965253726735; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (261:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (261:4)"; return _f; })(), [spacerIndexAnim] @@ -369,7 +369,7 @@ function DraggableFlatListInner(props) { "function _f(evt,state){const{enabled}=jsThis._closure;{if(enabled.value){state.activate();}else{state.fail();}}}"; _f.__workletHash = 12200938421428; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (273:19)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (273:19)"; return _f; })() ) @@ -389,7 +389,7 @@ function DraggableFlatListInner(props) { "function _f(evt){const{gestureDisabled,disabled,panGestureState}=jsThis._closure;{gestureDisabled.value=disabled.value;if(gestureDisabled.value)return;panGestureState.value=evt.state;}}"; _f.__workletHash = 17574034116918; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (280:13)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (280:13)"; return _f; })() ) @@ -413,7 +413,7 @@ function DraggableFlatListInner(props) { "function _f(evt){const{gestureDisabled,panGestureState,horizontalAnim,touchTranslate}=jsThis._closure;{if(gestureDisabled.value)return;panGestureState.value=evt.state;const translation=horizontalAnim.value?evt.translationX:evt.translationY;touchTranslate.value=translation;}}"; _f.__workletHash = 5455568984874; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (285:14)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (285:14)"; return _f; })() ) @@ -453,7 +453,7 @@ function DraggableFlatListInner(props) { "function _f(){const{runOnJS,onDragEnd,activeIndexAnim,spacerIndexAnim,disabled}=jsThis._closure;{runOnJS(onDragEnd)({from:activeIndexAnim.value,to:spacerIndexAnim.value});disabled.value=false;}}"; _f.__workletHash = 1618704508901; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (312:8)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (312:8)"; return _f; })() ); @@ -480,7 +480,7 @@ function DraggableFlatListInner(props) { "function _f(evt){const{gestureDisabled,isTouchActiveNative,horizontalAnim,touchTranslate,autoScrollDistance,panGestureState,activeIndexAnim,disabled,runOnJS,onRelease,placeholderOffset,activeCellOffset,withSpring,animationConfigRef,onDragEnd,spacerIndexAnim}=jsThis._closure;{if(gestureDisabled.value)return;isTouchActiveNative.value=false;const translation=horizontalAnim.value?evt.translationX:evt.translationY;touchTranslate.value=translation+autoScrollDistance.value;panGestureState.value=evt.state;if(activeIndexAnim.value===-1||disabled.value)return;disabled.value=true;runOnJS(onRelease)(activeIndexAnim.value);const springTo=placeholderOffset.value-activeCellOffset.value;touchTranslate.value=withSpring(springTo,animationConfigRef.current,function(){runOnJS(onDragEnd)({from:activeIndexAnim.value,to:spacerIndexAnim.value});disabled.value=false;});}}"; _f.__workletHash = 10097216425009; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (293:11)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (293:11)"; return _f; })() ) @@ -497,7 +497,7 @@ function DraggableFlatListInner(props) { "function _f(){const{runOnJS,onContainerTouchStart}=jsThis._closure;{runOnJS(onContainerTouchStart)();}}"; _f.__workletHash = 4756906064016; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (321:19)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (321:19)"; return _f; })() ) @@ -516,7 +516,7 @@ function DraggableFlatListInner(props) { "function _f(){const{enabled,runOnJS,onContainerTouchEnd}=jsThis._closure;{enabled.value=false;runOnJS(onContainerTouchEnd)();}}"; _f.__workletHash = 11574446621954; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (324:17)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (324:17)"; return _f; })() ); @@ -555,7 +555,7 @@ function DraggableFlatListInner(props) { "function _f(evt){const{scrollOffset,horizontalAnim,runOnJS,onScroll}=jsThis._closure;{scrollOffset.value=horizontalAnim.value?evt.contentOffset.x:evt.contentOffset.y;runOnJS(onScroll)(scrollOffset.value);}}"; _f.__workletHash = 5653789960368; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (347:16)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/DraggableFlatList.tsx (347:16)"; return _f; })(), }, diff --git a/lib/commonjs/components/DraggableFlatList.js.map b/lib/commonjs/components/DraggableFlatList.js.map index fdc29d2d..fc208198 100644 --- a/lib/commonjs/components/DraggableFlatList.js.map +++ b/lib/commonjs/components/DraggableFlatList.js.map @@ -1 +1 @@ -{"version":3,"names":["AnimatedFlatList","Animated","createAnimatedComponent","FlatList","DraggableFlatListInner","props","useRefs","cellDataRef","containerRef","flatlistRef","keyToIndexRef","propsRef","animationConfigRef","useAnimatedValues","activeCellOffset","activeCellSize","activeIndexAnim","containerSize","scrollOffset","scrollViewSize","spacerIndexAnim","horizontalAnim","placeholderOffset","touchTranslate","autoScrollDistance","panGestureState","isTouchActiveNative","viewableIndexMin","viewableIndexMax","disabled","enabled","useSharedValue","reset","useStableCallback","value","setActiveKey","dragHitSlop","DEFAULT_PROPS","scrollEnabled","activationDistance","activationDistanceProp","useState","activeKey","current","enableLayoutAnimationExperimental","layoutAnimationDisabled","setLayoutAnimationDisabled","keyExtractor","item","index","Error","dataRef","useRef","data","dataHasChanged","map","join","useEffect","setTimeout","useLayoutEffect","forEach","d","i","key","set","drag","get","cellData","measurements","offset","size","onDragBegin","undefined","onContainerLayout","layout","nativeEvent","width","height","horizontal","onListContentSizeChange","w","h","onContentSizeChange","onContainerTouchStart","onContainerTouchEnd","extraData","useMemo","renderItem","useCallback","panGesture","onRelease","onDragEnd","from","to","newData","splice","onPlaceholderIndexChange","useAnimatedReaction","cur","prev","hasMoved","runOnJS","gestureDisabled","Gesture","Pan","manualActivation","onTouchesMove","evt","state","activate","fail","onBegin","onUpdate","translation","translationX","translationY","onEnd","springTo","withSpring","onTouchesDown","onTouchesUp","hitSlop","activeOffset","activeOffsetX","activeOffsetY","onScroll","onScrollOffsetChange","scrollHandler","useAnimatedScrollHandler","contentOffset","x","y","useAutoScroll","onViewableItemsChanged","info","viewableIndices","viewableItems","filter","isViewable","min","Math","max","containerStyle","renderPlaceholder","CellRendererComponent","simultaneousHandlers","DraggableFlatList","ref","MemoizedInner","typedMemo","React","forwardRef"],"sources":["DraggableFlatList.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ListRenderItem, FlatListProps, LayoutChangeEvent } from \"react-native\";\nimport {\n FlatList,\n Gesture,\n GestureDetector,\n} from \"react-native-gesture-handler\";\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n useAnimatedScrollHandler,\n useSharedValue,\n withSpring,\n} from \"react-native-reanimated\";\nimport CellRendererComponent from \"./CellRendererComponent\";\nimport { DEFAULT_PROPS, isWeb } from \"../constants\";\nimport PlaceholderItem from \"./PlaceholderItem\";\nimport RowItem from \"./RowItem\";\nimport { DraggableFlatListProps } from \"../types\";\nimport PropsProvider from \"../context/propsContext\";\nimport AnimatedValueProvider, {\n useAnimatedValues,\n} from \"../context/animatedValueContext\";\nimport RefProvider, { useRefs } from \"../context/refContext\";\nimport DraggableFlatListProvider from \"../context/draggableFlatListContext\";\nimport { useAutoScroll } from \"../hooks/useAutoScroll\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport ScrollOffsetListener from \"./ScrollOffsetListener\";\nimport { typedMemo } from \"../utils\";\n\ntype RNGHFlatListProps = Animated.AnimateProps<\n FlatListProps & {\n ref: React.Ref>;\n simultaneousHandlers?: React.Ref | React.Ref[];\n }\n>;\n\ntype OnViewableItemsChangedCallback = Exclude<\n FlatListProps[\"onViewableItemsChanged\"],\n undefined | null\n>;\n\nconst AnimatedFlatList = (Animated.createAnimatedComponent(\n FlatList\n) as unknown) as (props: RNGHFlatListProps) => React.ReactElement;\n\nfunction DraggableFlatListInner(props: DraggableFlatListProps) {\n const {\n cellDataRef,\n containerRef,\n flatlistRef,\n keyToIndexRef,\n propsRef,\n animationConfigRef,\n } = useRefs();\n const {\n activeCellOffset,\n activeCellSize,\n activeIndexAnim,\n containerSize,\n scrollOffset,\n scrollViewSize,\n spacerIndexAnim,\n horizontalAnim,\n placeholderOffset,\n touchTranslate,\n autoScrollDistance,\n panGestureState,\n isTouchActiveNative,\n viewableIndexMin,\n viewableIndexMax,\n disabled,\n } = useAnimatedValues();\n\n const enabled = useSharedValue(false);\n\n const reset = useStableCallback(() => {\n activeIndexAnim.value = -1;\n spacerIndexAnim.value = -1;\n touchTranslate.value = 0;\n activeCellSize.value = -1;\n activeCellOffset.value = -1;\n setActiveKey(null);\n });\n\n const {\n dragHitSlop = DEFAULT_PROPS.dragHitSlop,\n scrollEnabled = DEFAULT_PROPS.scrollEnabled,\n activationDistance: activationDistanceProp = DEFAULT_PROPS.activationDistance,\n } = props;\n\n let [activeKey, setActiveKey] = useState(null);\n const [layoutAnimationDisabled, setLayoutAnimationDisabled] = useState(\n !propsRef.current.enableLayoutAnimationExperimental\n );\n\n const keyExtractor = useStableCallback((item: T, index: number) => {\n if (!props.keyExtractor) {\n throw new Error(\"You must provide a keyExtractor to DraggableFlatList\");\n }\n return props.keyExtractor(item, index);\n });\n\n const dataRef = useRef(props.data);\n const dataHasChanged =\n dataRef.current.map(keyExtractor).join(\"\") !==\n props.data.map(keyExtractor).join(\"\");\n dataRef.current = props.data;\n if (dataHasChanged) {\n // When data changes make sure `activeKey` is nulled out in the same render pass\n activeKey = null;\n }\n\n useEffect(() => {\n if (!propsRef.current.enableLayoutAnimationExperimental) return;\n if (activeKey) {\n setLayoutAnimationDisabled(true);\n } else {\n // setTimeout result of trial-and-error to determine how long to wait before\n // re-enabling layout animations so that a drag reorder does not trigger it.\n setTimeout(() => {\n setLayoutAnimationDisabled(false);\n }, 100);\n }\n }, [activeKey]);\n\n useLayoutEffect(() => {\n props.data.forEach((d, i) => {\n const key = keyExtractor(d, i);\n keyToIndexRef.current.set(key, i);\n });\n }, [props.data, keyExtractor, keyToIndexRef]);\n\n const drag = useStableCallback((activeKey: string) => {\n if (disabled.value) return;\n\n const index = keyToIndexRef.current.get(activeKey);\n const cellData = cellDataRef.current.get(activeKey);\n if (cellData) {\n activeCellOffset.value = cellData.measurements.offset;\n activeCellSize.value = cellData.measurements.size;\n }\n\n const { onDragBegin } = propsRef.current;\n if (index !== undefined) {\n spacerIndexAnim.value = index;\n activeIndexAnim.value = index;\n setActiveKey(activeKey);\n onDragBegin?.(index);\n }\n });\n\n const onContainerLayout = ({\n nativeEvent: { layout },\n }: LayoutChangeEvent) => {\n const { width, height } = layout;\n containerSize.value = props.horizontal ? width : height;\n props.onContainerLayout?.({ layout, containerRef });\n };\n\n const onListContentSizeChange = (w: number, h: number) => {\n scrollViewSize.value = props.horizontal ? w : h;\n props.onContentSizeChange?.(w, h);\n };\n\n const onContainerTouchStart = () => {\n if (!disabled.value) {\n isTouchActiveNative.value = true;\n }\n return false;\n };\n\n const onContainerTouchEnd = () => {\n isTouchActiveNative.value = false;\n };\n\n const extraData = useMemo(\n () => ({\n activeKey,\n extraData: props.extraData,\n }),\n [activeKey, props.extraData]\n );\n\n const renderItem: ListRenderItem = useCallback(\n ({ item, index }) => {\n const key = keyExtractor(item, index);\n if (index !== keyToIndexRef.current.get(key)) {\n keyToIndexRef.current.set(key, index);\n }\n\n return (\n \n );\n },\n [props.renderItem, props.extraData, drag, keyExtractor]\n );\n\n const onRelease = useStableCallback((index: number) => {\n props.onRelease?.(index);\n });\n\n const onDragEnd = useStableCallback(\n ({ from, to }: { from: number; to: number }) => {\n const { onDragEnd, data } = props;\n\n const newData = [...data];\n if (from !== to) {\n newData.splice(from, 1);\n newData.splice(to, 0, data[from]);\n }\n\n onDragEnd?.({ from, to, data: newData });\n reset();\n }\n );\n\n const onPlaceholderIndexChange = useStableCallback((index: number) => {\n props.onPlaceholderIndexChange?.(index);\n });\n\n // Handle case where user ends drag without moving their finger.\n useAnimatedReaction(\n () => {\n return isTouchActiveNative.value;\n },\n (cur, prev) => {\n if (cur !== prev && !cur) {\n const hasMoved = !!touchTranslate.value;\n if (!hasMoved && activeIndexAnim.value >= 0 && !disabled.value) {\n runOnJS(onRelease)(activeIndexAnim.value);\n runOnJS(onDragEnd)({\n from: activeIndexAnim.value,\n to: spacerIndexAnim.value,\n });\n }\n }\n },\n [isTouchActiveNative, onDragEnd, onRelease]\n );\n\n useAnimatedReaction(\n () => {\n return spacerIndexAnim.value;\n },\n (cur, prev) => {\n if (prev !== null && cur !== prev && cur >= 0 && prev >= 0) {\n runOnJS(onPlaceholderIndexChange)(cur);\n }\n },\n [spacerIndexAnim]\n );\n\n const gestureDisabled = useSharedValue(false);\n\n const panGesture = Gesture.Pan()\n .manualActivation(true)\n .onTouchesMove((evt, state) => {\n if (enabled.value) {\n state.activate();\n } else {\n state.fail();\n }\n })\n .onBegin((evt) => {\n gestureDisabled.value = disabled.value;\n if (gestureDisabled.value) return;\n panGestureState.value = evt.state;\n })\n .onUpdate((evt) => {\n if (gestureDisabled.value) return;\n panGestureState.value = evt.state;\n const translation = horizontalAnim.value\n ? evt.translationX\n : evt.translationY;\n touchTranslate.value = translation;\n })\n .onEnd((evt) => {\n if (gestureDisabled.value) return;\n // Set touch val to current translate val\n isTouchActiveNative.value = false;\n const translation = horizontalAnim.value\n ? evt.translationX\n : evt.translationY;\n\n touchTranslate.value = translation + autoScrollDistance.value;\n panGestureState.value = evt.state;\n\n // Only call onDragEnd if actually dragging a cell\n if (activeIndexAnim.value === -1 || disabled.value) return;\n disabled.value = true;\n runOnJS(onRelease)(activeIndexAnim.value);\n const springTo = placeholderOffset.value - activeCellOffset.value;\n touchTranslate.value = withSpring(\n springTo,\n animationConfigRef.current,\n () => {\n runOnJS(onDragEnd)({\n from: activeIndexAnim.value,\n to: spacerIndexAnim.value,\n });\n disabled.value = false;\n }\n );\n })\n .onTouchesDown(() => {\n runOnJS(onContainerTouchStart)();\n })\n .onTouchesUp(() => {\n // Turning this into a worklet causes timing issues. We want it to run\n // just after the finger lifts.\n enabled.value = false;\n runOnJS(onContainerTouchEnd)();\n });\n\n if (dragHitSlop) panGesture.hitSlop(dragHitSlop);\n if (activationDistanceProp) {\n const activeOffset = [-activationDistanceProp, activationDistanceProp];\n if (props.horizontal) {\n panGesture.activeOffsetX(activeOffset);\n } else {\n panGesture.activeOffsetY(activeOffset);\n }\n }\n\n const onScroll = useStableCallback((scrollOffset: number) => {\n props.onScrollOffsetChange?.(scrollOffset);\n });\n\n const scrollHandler = useAnimatedScrollHandler(\n {\n onScroll: (evt) => {\n scrollOffset.value = horizontalAnim.value\n ? evt.contentOffset.x\n : evt.contentOffset.y;\n runOnJS(onScroll)(scrollOffset.value);\n },\n },\n [horizontalAnim]\n );\n\n useAutoScroll();\n\n const onViewableItemsChanged = useStableCallback<\n OnViewableItemsChangedCallback\n >((info) => {\n const viewableIndices = info.viewableItems\n .filter((item) => item.isViewable)\n .map((item) => item.index)\n .filter((index): index is number => typeof index === \"number\");\n\n const min = Math.min(...viewableIndices);\n const max = Math.max(...viewableIndices);\n viewableIndexMin.value = min;\n viewableIndexMax.value = max;\n props.onViewableItemsChanged?.(info);\n });\n\n return (\n \n \n \n {props.renderPlaceholder && (\n \n )}\n \n {!!props.onScrollOffsetChange && (\n \n )}\n \n \n \n );\n}\n\nfunction DraggableFlatList(\n props: DraggableFlatListProps,\n ref?: React.ForwardedRef> | null\n) {\n return (\n \n \n \n \n \n \n \n );\n}\n\nconst MemoizedInner = typedMemo(DraggableFlatListInner);\n\n// Generic forwarded ref type assertion taken from:\n// https://fettblog.eu/typescript-react-generic-forward-refs/#option-1%3A-type-assertion\nexport default React.forwardRef(DraggableFlatList) as (\n props: DraggableFlatListProps & { ref?: React.ForwardedRef> }\n) => ReturnType;\n"],"mappings":"mbAAA,qDASA,uEAKA,uFAOA,sFACA,uCACA,0EACA,0DAEA,6EACA,8FAGA,0EACA,qGACA,qDACA,6DACA,oFACA,+B,imCAcA,GAAMA,iBAAgB,CAAIC,8BAAA,CAASC,uBAAT,CACxBC,mCADwB,CAA1B,CAIA,QAASC,uBAAT,CAAmCC,KAAnC,CAAqE,6BAQ/D,GAAAC,mBAAA,GAR+D,CAEjEC,WAFiE,UAEjEA,WAFiE,CAGjEC,YAHiE,UAGjEA,YAHiE,CAIjEC,WAJiE,UAIjEA,WAJiE,CAKjEC,aALiE,UAKjEA,aALiE,CAMjEC,QANiE,UAMjEA,QANiE,CAOjEC,kBAPiE,UAOjEA,kBAPiE,wBA0B/D,GAAAC,uCAAA,GA1B+D,CAUjEC,gBAViE,oBAUjEA,gBAViE,CAWjEC,cAXiE,oBAWjEA,cAXiE,CAYjEC,eAZiE,oBAYjEA,eAZiE,CAajEC,aAbiE,oBAajEA,aAbiE,CAcjEC,YAdiE,oBAcjEA,YAdiE,CAejEC,cAfiE,oBAejEA,cAfiE,CAgBjEC,eAhBiE,oBAgBjEA,eAhBiE,CAiBjEC,cAjBi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AK,CAACyH,oBAD9B,CAEE,YAAY,CAAE5G,YAFhB,8EAzBJ,CADF,CANF,CADF,CA0CD,CAED,QAASgI,kBAAT,CACE7I,KADF,CAEE8I,GAFF,CAGE,CACA,MACE,8BAAC,qBAAD,0BAAmB9I,KAAnB,+EACE,6BAAC,6BAAD,8EACE,6BAAC,mBAAD,EAAa,WAAW,CAAE8I,GAA1B,6EACE,6BAAC,aAAD,0BAAmB9I,KAAnB,gFADF,CADF,CADF,CADF,CASD,CAED,GAAM+I,cAAa,CAAG,GAAAC,gBAAA,EAAUjJ,sBAAV,CAAtB,C,aAIekJ,cAAA,CAAMC,UAAN,CAAiBL,iBAAjB,C"} \ No newline at end of file +{"version":3,"names":["AnimatedFlatList","Animated","createAnimatedComponent","FlatList","DraggableFlatListInner","props","useRefs","cellDataRef","containerRef","flatlistRef","keyToIndexRef","propsRef","animationConfigRef","useAnimatedValues","activeCellOffset","activeCellSize","activeIndexAnim","containerSize","scrollOffset","scrollViewSize","spacerIndexAnim","horizontalAnim","placeholderOffset","touchTranslate","autoScrollDistance","panGestureState","isTouchActiveNative","viewableIndexMin","viewableIndexMax","disabled","enabled","useSharedValue","reset","useStableCallback","value","setActiveKey","dragHitSlop","DEFAULT_PROPS","scrollEnabled","activationDistance","activationDistanceProp","useState","activeKey","current","enableLayoutAnimationExperimental","layoutAnimationDisabled","setLayoutAnimationDisabled","keyExtractor","item","index","Error","dataRef","useRef","data","dataHasChanged","map","join","useEffect","setTimeout","useLayoutEffect","forEach","d","i","key","set","drag","get","cellData","measurements","offset","size","onDragBegin","undefined","onContainerLayout","layout","nativeEvent","width","height","horizontal","onListContentSizeChange","w","h","onContentSizeChange","onContainerTouchStart","onContainerTouchEnd","extraData","useMemo","renderItem","useCallback","panGesture","onRelease","onDragEnd","from","to","newData","splice","onPlaceholderIndexChange","useAnimatedReaction","cur","prev","hasMoved","runOnJS","gestureDisabled","Gesture","Pan","manualActivation","onTouchesMove","evt","state","activate","fail","onBegin","onUpdate","translation","translationX","translationY","onEnd","springTo","withSpring","onTouchesDown","onTouchesUp","hitSlop","activeOffset","activeOffsetX","activeOffsetY","onScroll","onScrollOffsetChange","scrollHandler","useAnimatedScrollHandler","contentOffset","x","y","useAutoScroll","onViewableItemsChanged","info","viewableIndices","viewableItems","filter","isViewable","min","Math","max","containerStyle","renderPlaceholder","CellRendererComponent","simultaneousHandlers","DraggableFlatList","ref","MemoizedInner","typedMemo","React","forwardRef"],"sources":["DraggableFlatList.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { ListRenderItem, FlatListProps, LayoutChangeEvent } from \"react-native\";\nimport {\n FlatList,\n Gesture,\n GestureDetector,\n} from \"react-native-gesture-handler\";\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n useAnimatedScrollHandler,\n useSharedValue,\n withSpring,\n} from \"react-native-reanimated\";\nimport CellRendererComponent from \"./CellRendererComponent\";\nimport { DEFAULT_PROPS, isWeb } from \"../constants\";\nimport PlaceholderItem from \"./PlaceholderItem\";\nimport RowItem from \"./RowItem\";\nimport { DraggableFlatListProps } from \"../types\";\nimport PropsProvider from \"../context/propsContext\";\nimport AnimatedValueProvider, {\n useAnimatedValues,\n} from \"../context/animatedValueContext\";\nimport RefProvider, { useRefs } from \"../context/refContext\";\nimport DraggableFlatListProvider from \"../context/draggableFlatListContext\";\nimport { useAutoScroll } from \"../hooks/useAutoScroll\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport ScrollOffsetListener from \"./ScrollOffsetListener\";\nimport { typedMemo } from \"../utils\";\n\ntype RNGHFlatListProps = Animated.AnimateProps<\n FlatListProps & {\n ref: React.Ref>;\n simultaneousHandlers?: React.Ref | React.Ref[];\n }\n>;\n\ntype OnViewableItemsChangedCallback = Exclude<\n FlatListProps[\"onViewableItemsChanged\"],\n undefined | null\n>;\n\nconst AnimatedFlatList = (Animated.createAnimatedComponent(\n FlatList\n) as unknown) as (props: RNGHFlatListProps) => React.ReactElement;\n\nfunction DraggableFlatListInner(props: DraggableFlatListProps) {\n const {\n cellDataRef,\n containerRef,\n flatlistRef,\n keyToIndexRef,\n propsRef,\n animationConfigRef,\n } = useRefs();\n const {\n activeCellOffset,\n activeCellSize,\n activeIndexAnim,\n containerSize,\n scrollOffset,\n scrollViewSize,\n spacerIndexAnim,\n horizontalAnim,\n placeholderOffset,\n touchTranslate,\n autoScrollDistance,\n panGestureState,\n isTouchActiveNative,\n viewableIndexMin,\n viewableIndexMax,\n disabled,\n } = useAnimatedValues();\n\n const enabled = useSharedValue(false);\n\n const reset = useStableCallback(() => {\n activeIndexAnim.value = -1;\n spacerIndexAnim.value = -1;\n touchTranslate.value = 0;\n activeCellSize.value = -1;\n activeCellOffset.value = -1;\n setActiveKey(null);\n });\n\n const {\n dragHitSlop = DEFAULT_PROPS.dragHitSlop,\n scrollEnabled = DEFAULT_PROPS.scrollEnabled,\n activationDistance: activationDistanceProp = DEFAULT_PROPS.activationDistance,\n } = props;\n\n let [activeKey, setActiveKey] = useState(null);\n const [layoutAnimationDisabled, setLayoutAnimationDisabled] = useState(\n !propsRef.current.enableLayoutAnimationExperimental\n );\n\n const keyExtractor = useStableCallback((item: T, index: number) => {\n if (!props.keyExtractor) {\n throw new Error(\"You must provide a keyExtractor to DraggableFlatList\");\n }\n return props.keyExtractor(item, index);\n });\n\n const dataRef = useRef(props.data);\n const dataHasChanged =\n dataRef.current.map(keyExtractor).join(\"\") !==\n props.data.map(keyExtractor).join(\"\");\n dataRef.current = props.data;\n if (dataHasChanged) {\n // When data changes make sure `activeKey` is nulled out in the same render pass\n activeKey = null;\n }\n\n useEffect(() => {\n if (!propsRef.current.enableLayoutAnimationExperimental) return;\n if (activeKey) {\n setLayoutAnimationDisabled(true);\n } else {\n // setTimeout result of trial-and-error to determine how long to wait before\n // re-enabling layout animations so that a drag reorder does not trigger it.\n setTimeout(() => {\n setLayoutAnimationDisabled(false);\n }, 100);\n }\n }, [activeKey]);\n\n useLayoutEffect(() => {\n props.data.forEach((d, i) => {\n const key = keyExtractor(d, i);\n keyToIndexRef.current.set(key, i);\n });\n }, [props.data, keyExtractor, keyToIndexRef]);\n\n const drag = useStableCallback((activeKey: string) => {\n if (disabled.value) return;\n\n const index = keyToIndexRef.current.get(activeKey);\n const cellData = cellDataRef.current.get(activeKey);\n if (cellData) {\n activeCellOffset.value = cellData.measurements.offset;\n activeCellSize.value = cellData.measurements.size;\n }\n\n const { onDragBegin } = propsRef.current;\n if (index !== undefined) {\n spacerIndexAnim.value = index;\n activeIndexAnim.value = index;\n setActiveKey(activeKey);\n onDragBegin?.(index);\n }\n });\n\n const onContainerLayout = ({\n nativeEvent: { layout },\n }: LayoutChangeEvent) => {\n const { width, height } = layout;\n containerSize.value = props.horizontal ? width : height;\n props.onContainerLayout?.({ layout, containerRef });\n };\n\n const onListContentSizeChange = (w: number, h: number) => {\n scrollViewSize.value = props.horizontal ? w : h;\n props.onContentSizeChange?.(w, h);\n };\n\n const onContainerTouchStart = () => {\n if (!disabled.value) {\n isTouchActiveNative.value = true;\n }\n return false;\n };\n\n const onContainerTouchEnd = () => {\n isTouchActiveNative.value = false;\n };\n\n const extraData = useMemo(\n () => ({\n activeKey,\n extraData: props.extraData,\n }),\n [activeKey, props.extraData]\n );\n\n const renderItem: ListRenderItem = useCallback(\n ({ item, index }) => {\n const key = keyExtractor(item, index);\n if (index !== keyToIndexRef.current.get(key)) {\n keyToIndexRef.current.set(key, index);\n }\n\n return (\n \n );\n },\n [props.renderItem, props.extraData, drag, keyExtractor]\n );\n\n const onRelease = useStableCallback((index: number) => {\n props.onRelease?.(index);\n });\n\n const onDragEnd = useStableCallback(\n ({ from, to }: { from: number; to: number }) => {\n const { onDragEnd, data } = props;\n\n const newData = [...data];\n if (from !== to) {\n newData.splice(from, 1);\n newData.splice(to, 0, data[from]);\n }\n\n onDragEnd?.({ from, to, data: newData });\n reset();\n }\n );\n\n const onPlaceholderIndexChange = useStableCallback((index: number) => {\n props.onPlaceholderIndexChange?.(index);\n });\n\n // Handle case where user ends drag without moving their finger.\n useAnimatedReaction(\n () => {\n return isTouchActiveNative.value;\n },\n (cur, prev) => {\n if (cur !== prev && !cur) {\n const hasMoved = !!touchTranslate.value;\n if (!hasMoved && activeIndexAnim.value >= 0 && !disabled.value) {\n runOnJS(onRelease)(activeIndexAnim.value);\n runOnJS(onDragEnd)({\n from: activeIndexAnim.value,\n to: spacerIndexAnim.value,\n });\n }\n }\n },\n [isTouchActiveNative, onDragEnd, onRelease]\n );\n\n useAnimatedReaction(\n () => {\n return spacerIndexAnim.value;\n },\n (cur, prev) => {\n if (prev !== null && cur !== prev && cur >= 0 && prev >= 0) {\n runOnJS(onPlaceholderIndexChange)(cur);\n }\n },\n [spacerIndexAnim]\n );\n\n const gestureDisabled = useSharedValue(false);\n\n const panGesture = Gesture.Pan()\n .manualActivation(true)\n .onTouchesMove((evt, state) => {\n if (enabled.value) {\n state.activate();\n } else {\n state.fail();\n }\n })\n .onBegin((evt) => {\n gestureDisabled.value = disabled.value;\n if (gestureDisabled.value) return;\n panGestureState.value = evt.state;\n })\n .onUpdate((evt) => {\n if (gestureDisabled.value) return;\n panGestureState.value = evt.state;\n const translation = horizontalAnim.value\n ? evt.translationX\n : evt.translationY;\n touchTranslate.value = translation;\n })\n .onEnd((evt) => {\n if (gestureDisabled.value) return;\n // Set touch val to current translate val\n isTouchActiveNative.value = false;\n const translation = horizontalAnim.value\n ? evt.translationX\n : evt.translationY;\n\n touchTranslate.value = translation + autoScrollDistance.value;\n panGestureState.value = evt.state;\n\n // Only call onDragEnd if actually dragging a cell\n if (activeIndexAnim.value === -1 || disabled.value) return;\n disabled.value = true;\n runOnJS(onRelease)(activeIndexAnim.value);\n const springTo = placeholderOffset.value - activeCellOffset.value;\n touchTranslate.value = withSpring(\n springTo,\n animationConfigRef.current,\n () => {\n runOnJS(onDragEnd)({\n from: activeIndexAnim.value,\n to: spacerIndexAnim.value,\n });\n disabled.value = false;\n }\n );\n })\n .onTouchesDown(() => {\n runOnJS(onContainerTouchStart)();\n })\n .onTouchesUp(() => {\n // Turning this into a worklet causes timing issues. We want it to run\n // just after the finger lifts.\n enabled.value = false;\n runOnJS(onContainerTouchEnd)();\n });\n\n if (dragHitSlop) panGesture.hitSlop(dragHitSlop);\n if (activationDistanceProp) {\n const activeOffset = [-activationDistanceProp, activationDistanceProp];\n if (props.horizontal) {\n panGesture.activeOffsetX(activeOffset);\n } else {\n panGesture.activeOffsetY(activeOffset);\n }\n }\n\n const onScroll = useStableCallback((scrollOffset: number) => {\n props.onScrollOffsetChange?.(scrollOffset);\n });\n\n const scrollHandler = useAnimatedScrollHandler(\n {\n onScroll: (evt) => {\n scrollOffset.value = horizontalAnim.value\n ? evt.contentOffset.x\n : evt.contentOffset.y;\n runOnJS(onScroll)(scrollOffset.value);\n },\n },\n [horizontalAnim]\n );\n\n useAutoScroll();\n\n const onViewableItemsChanged = useStableCallback<\n OnViewableItemsChangedCallback\n >((info) => {\n const viewableIndices = info.viewableItems\n .filter((item) => item.isViewable)\n .map((item) => item.index)\n .filter((index): index is number => typeof index === \"number\");\n\n const min = Math.min(...viewableIndices);\n const max = Math.max(...viewableIndices);\n viewableIndexMin.value = min;\n viewableIndexMax.value = max;\n props.onViewableItemsChanged?.(info);\n });\n\n return (\n \n \n \n {props.renderPlaceholder && (\n \n )}\n \n {!!props.onScrollOffsetChange && (\n \n )}\n \n \n \n );\n}\n\nfunction DraggableFlatList(\n props: DraggableFlatListProps,\n ref?: React.ForwardedRef> | null\n) {\n return (\n \n \n \n \n \n \n \n );\n}\n\nconst MemoizedInner = typedMemo(DraggableFlatListInner);\n\n// Generic forwarded ref type assertion taken from:\n// https://fettblog.eu/typescript-react-generic-forward-refs/#option-1%3A-type-assertion\nexport default React.forwardRef(DraggableFlatList) as (\n props: DraggableFlatListProps & { ref?: React.ForwardedRef> }\n) => ReturnType;\n"],"mappings":"mbAAA,qDASA,uEAKA,uFAOA,sFACA,uCACA,0EACA,0DAEA,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CAAEiE,iBAHZ,6EAKGpE,KAAK,CAAC0I,iBAAN,EACC,6BAAC,wBAAD,EAAiB,iBAAiB,CAAE1I,KAAK,CAAC0I,iBAA1C,8EANJ,CAQE,6BAAC,gBAAD,0BACM1I,KADN,EAEE,IAAI,CAAEA,KAAK,CAACgD,IAFd,CAGE,sBAAsB,CAAEgF,sBAH1B,CAIE,qBAAqB,CAAEW,8BAJzB,CAKE,GAAG,CAAEvI,WALP,CAME,mBAAmB,CAAEsE,uBANvB,CAOE,aAAa,CAAE,CAACrC,SAAD,EAAcJ,aAP/B,CAQE,UAAU,CAAEiD,UARd,CASE,SAAS,CAAEF,SATb,CAUE,YAAY,CAAEtC,YAVhB,CAWE,QAAQ,CAAEgF,aAXZ,CAYE,mBAAmB,CAAE,EAZvB,CAaE,oBAAoB,CAAE1H,KAAK,CAAC4I,oBAb9B,CAcE,qBAAqB,CAAE,KAdzB,+EARF,CAwBG,CAAC,CAAC5I,KAAK,CAACyH,oBAAR,EACC,6BAAC,6BAAD,EACE,oBAAoB,CAAEzH,KAAK,CAACyH,oBAD9B,CAEE,YAAY,CAAE5G,YAFhB,8EAzBJ,CADF,CANF,CADF,CA0CD,CAED,QAASgI,kBAAT,CACE7I,KADF,CAEE8I,GAFF,CAGE,CACA,MACE,8BAAC,qBAAD,0BAAmB9I,KAAnB,+EACE,6BAAC,6BAAD,8EACE,6BAAC,mBAAD,EAAa,WAAW,CAAE8I,GAA1B,6EACE,6BAAC,aAAD,0BAAmB9I,KAAnB,gFADF,CADF,CADF,CADF,CASD,CAED,GAAM+I,cAAa,CAAG,GAAAC,gBAAA,EAAUjJ,sBAAV,CAAtB,C,aAIekJ,cAAA,CAAMC,UAAN,CAAiBL,iBAAjB,C"} \ No newline at end of file diff --git a/lib/commonjs/components/NestableDraggableFlatList.js b/lib/commonjs/components/NestableDraggableFlatList.js index 187f61ea..a5e63257 100644 --- a/lib/commonjs/components/NestableDraggableFlatList.js +++ b/lib/commonjs/components/NestableDraggableFlatList.js @@ -20,7 +20,7 @@ var _nestableScrollContainerContext = require("../context/nestableScrollContaine var _useNestedAutoScroll = require("../hooks/useNestedAutoScroll"); var _useStableCallback = require("../hooks/useStableCallback"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/NestableDraggableFlatList.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/NestableDraggableFlatList.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); @@ -100,7 +100,7 @@ function NestableDraggableFlatListInner(props, ref) { "function _f(){const{listHoverOffset,listVerticalOffset}=jsThis._closure;{return listHoverOffset.value+listVerticalOffset.value;}}"; _f.__workletHash = 4066479402801; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/NestableDraggableFlatList.tsx (41:38)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/NestableDraggableFlatList.tsx (41:38)"; return _f; })(), [listHoverOffset] diff --git a/lib/commonjs/components/NestableDraggableFlatList.js.map b/lib/commonjs/components/NestableDraggableFlatList.js.map index 242a5a31..8ba34feb 100644 --- a/lib/commonjs/components/NestableDraggableFlatList.js.map +++ b/lib/commonjs/components/NestableDraggableFlatList.js.map @@ -1 +1 @@ -{"version":3,"names":["NestableDraggableFlatListInner","props","ref","hasSuppressedWarnings","useRef","current","LogBox","ignoreLogs","console","reportErrorsAsExceptions","useSafeNestableScrollContainerContext","scrollableRef","outerScrollOffset","setOuterScrollEnabled","listVerticalOffset","useSharedValue","useState","animVals","setAnimVals","defaultHoverOffset","listHoverOffset","setListHoverOffset","hoverOffset","useDerivedValue","value","useNestedAutoScroll","onListContainerLayout","useStableCallback","containerRef","nodeHandle","findNodeHandle","onSuccess","_x","y","onFail","log","measureLayout","onDragBegin","params","onDragEnd","onAnimValInit","activationDistance","NestableDraggableFlatList","React","forwardRef"],"sources":["NestableDraggableFlatList.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { findNodeHandle, LogBox } from \"react-native\";\nimport Animated, {\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { DraggableFlatListProps } from \"../types\";\nimport DraggableFlatList from \"../components/DraggableFlatList\";\nimport { useSafeNestableScrollContainerContext } from \"../context/nestableScrollContainerContext\";\nimport { useNestedAutoScroll } from \"../hooks/useNestedAutoScroll\";\nimport { typedMemo } from \"../utils\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport { FlatList } from \"react-native-gesture-handler\";\n\nfunction NestableDraggableFlatListInner(\n props: DraggableFlatListProps,\n ref?: React.ForwardedRef>\n) {\n const hasSuppressedWarnings = useRef(false);\n\n if (!hasSuppressedWarnings.current) {\n LogBox.ignoreLogs([\n \"VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing\",\n ]); // Ignore log notification by message\n //@ts-ignore\n console.reportErrorsAsExceptions = false;\n hasSuppressedWarnings.current = true;\n }\n\n const {\n scrollableRef,\n outerScrollOffset,\n setOuterScrollEnabled,\n } = useSafeNestableScrollContainerContext();\n\n const listVerticalOffset = useSharedValue(0);\n const [animVals, setAnimVals] = useState({});\n const defaultHoverOffset = useSharedValue(0);\n const [listHoverOffset, setListHoverOffset] = useState(defaultHoverOffset);\n\n const hoverOffset = useDerivedValue(() => {\n return listHoverOffset.value + listVerticalOffset.value;\n }, [listHoverOffset]);\n\n useNestedAutoScroll({\n ...animVals,\n hoverOffset,\n });\n\n const onListContainerLayout = useStableCallback(async ({ containerRef }) => {\n const nodeHandle = findNodeHandle(scrollableRef.current);\n\n const onSuccess = (_x: number, y: number) => {\n listVerticalOffset.value = y;\n };\n const onFail = () => {\n console.log(\"## nested draggable list measure fail\");\n };\n //@ts-ignore\n containerRef.current.measureLayout(nodeHandle, onSuccess, onFail);\n });\n\n const onDragBegin: DraggableFlatListProps[\"onDragBegin\"] = useStableCallback(\n (params) => {\n setOuterScrollEnabled(false);\n props.onDragBegin?.(params);\n }\n );\n\n const onDragEnd: DraggableFlatListProps[\"onDragEnd\"] = useStableCallback(\n (params) => {\n setOuterScrollEnabled(true);\n props.onDragEnd?.(params);\n }\n );\n\n const onAnimValInit: DraggableFlatListProps[\"onAnimValInit\"] = useStableCallback(\n (params) => {\n setListHoverOffset(params.hoverOffset);\n setAnimVals({\n ...params,\n hoverOffset,\n });\n props.onAnimValInit?.(params);\n }\n );\n\n return (\n \n );\n}\n\n// Generic forwarded ref type assertion taken from:\n// https://fettblog.eu/typescript-react-generic-forward-refs/#option-1%3A-type-assertion\nexport const NestableDraggableFlatList = React.forwardRef(\n NestableDraggableFlatListInner\n) as (\n props: DraggableFlatListProps & { ref?: React.ForwardedRef> }\n) => ReturnType;\n"],"mappings":"mcAAA,qDACA,yCACA,8DAKA,0FACA,yFACA,iEAEA,6D,ymCAGA,QAASA,+BAAT,CACEC,KADF,CAEEC,GAFF,CAGE,CACA,GAAMC,sBAAqB,CAAG,GAAAC,aAAA,EAAO,KAAP,CAA9B,CAEA,GAAI,CAACD,qBAAqB,CAACE,OAA3B,CAAoC,CAClCC,mBAAA,CAAOC,UAAP,CAAkB,CAChB,2HADgB,CAAlB,EAIAC,OAAO,CAACC,wBAAR,CAAmC,KAAnC,CACAN,qBAAqB,CAACE,OAAtB,CAAgC,IAAhC,CACD,CAVD,0BAgBI,GAAAK,qEAAA,GAhBJ,CAaEC,aAbF,uBAaEA,aAbF,CAcEC,iBAdF,uBAcEA,iBAdF,CAeEC,qBAfF,uBAeEA,qBAfF,CAkBA,GAAMC,mBAAkB,CAAG,GAAAC,qCAAA,EAAe,CAAf,CAA3B,CAlBA,cAmBgC,GAAAC,eAAA,EAAS,EAAT,CAnBhC,qDAmBOC,QAnBP,eAmBiBC,WAnBjB,eAoBA,GAAMC,mBAAkB,CAAG,GAAAJ,qCAAA,EAAe,CAAf,CAA3B,CApBA,eAqB8C,GAAAC,eAAA,EAASG,kBAAT,CArB9C,sDAqBOC,eArBP,eAqBwBC,kBArBxB,eAuBA,GAAMC,YAAW,CAAG,G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ACNoB,MADM,EAEThB,WAAW,CAAXA,WAFS,GAAX,CAIArB,KAAK,CAACuC,aAAN,cAAAvC,KAAK,CAACuC,aAAN,CAAsBF,MAAtB,EACD,CAR+D,CAAlE,CAWA,MACE,8BAAC,0BAAD,wBACE,GAAG,CAAEpC,GADP,CAEE,iBAAiB,CAAEwB,qBAFrB,CAGE,kBAAkB,CAAEzB,KAAK,CAACwC,kBAAN,EAA4B,EAHlD,CAIE,aAAa,CAAE,KAJjB,EAKMxC,KALN,EAME,iBAAiB,CAAEW,iBANrB,CAOE,WAAW,CAAEyB,WAPf,CAQE,SAAS,CAAEE,SARb,CASE,aAAa,CAAEC,aATjB,6EADF,CAaD,CAIM,GAAME,0BAAyB,CAAGC,cAAA,CAAMC,UAAN,CACvC5C,8BADuC,CAAlC,C"} \ No newline at end of file +{"version":3,"names":["NestableDraggableFlatListInner","props","ref","hasSuppressedWarnings","useRef","current","LogBox","ignoreLogs","console","reportErrorsAsExceptions","useSafeNestableScrollContainerContext","scrollableRef","outerScrollOffset","setOuterScrollEnabled","listVerticalOffset","useSharedValue","useState","animVals","setAnimVals","defaultHoverOffset","listHoverOffset","setListHoverOffset","hoverOffset","useDerivedValue","value","useNestedAutoScroll","onListContainerLayout","useStableCallback","containerRef","nodeHandle","findNodeHandle","onSuccess","_x","y","onFail","log","measureLayout","onDragBegin","params","onDragEnd","onAnimValInit","activationDistance","NestableDraggableFlatList","React","forwardRef"],"sources":["NestableDraggableFlatList.tsx"],"sourcesContent":["import React, { useRef, useState } from \"react\";\nimport { findNodeHandle, LogBox } from \"react-native\";\nimport Animated, {\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { DraggableFlatListProps } from \"../types\";\nimport DraggableFlatList from \"../components/DraggableFlatList\";\nimport { useSafeNestableScrollContainerContext } from \"../context/nestableScrollContainerContext\";\nimport { useNestedAutoScroll } from \"../hooks/useNestedAutoScroll\";\nimport { typedMemo } from \"../utils\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport { FlatList } from \"react-native-gesture-handler\";\n\nfunction NestableDraggableFlatListInner(\n props: DraggableFlatListProps,\n ref?: React.ForwardedRef>\n) {\n const hasSuppressedWarnings = useRef(false);\n\n if (!hasSuppressedWarnings.current) {\n LogBox.ignoreLogs([\n \"VirtualizedLists should never be nested inside plain ScrollViews with the same orientation because it can break windowing\",\n ]); // Ignore log notification by message\n //@ts-ignore\n console.reportErrorsAsExceptions = false;\n hasSuppressedWarnings.current = true;\n }\n\n const {\n scrollableRef,\n outerScrollOffset,\n setOuterScrollEnabled,\n } = useSafeNestableScrollContainerContext();\n\n const listVerticalOffset = useSharedValue(0);\n const [animVals, setAnimVals] = useState({});\n const defaultHoverOffset = useSharedValue(0);\n const [listHoverOffset, setListHoverOffset] = useState(defaultHoverOffset);\n\n const hoverOffset = useDerivedValue(() => {\n return listHoverOffset.value + listVerticalOffset.value;\n }, [listHoverOffset]);\n\n useNestedAutoScroll({\n ...animVals,\n hoverOffset,\n });\n\n const onListContainerLayout = useStableCallback(async ({ containerRef }) => {\n const nodeHandle = findNodeHandle(scrollableRef.current);\n\n const onSuccess = (_x: number, y: number) => {\n listVerticalOffset.value = y;\n };\n const onFail = () => {\n console.log(\"## nested draggable list measure fail\");\n };\n //@ts-ignore\n containerRef.current.measureLayout(nodeHandle, onSuccess, onFail);\n });\n\n const onDragBegin: DraggableFlatListProps[\"onDragBegin\"] = useStableCallback(\n (params) => {\n setOuterScrollEnabled(false);\n props.onDragBegin?.(params);\n }\n );\n\n const onDragEnd: DraggableFlatListProps[\"onDragEnd\"] = useStableCallback(\n (params) => {\n setOuterScrollEnabled(true);\n props.onDragEnd?.(params);\n }\n );\n\n const onAnimValInit: DraggableFlatListProps[\"onAnimValInit\"] = useStableCallback(\n (params) => {\n setListHoverOffset(params.hoverOffset);\n setAnimVals({\n ...params,\n hoverOffset,\n });\n props.onAnimValInit?.(params);\n }\n );\n\n return (\n \n );\n}\n\n// Generic forwarded ref type assertion taken from:\n// https://fettblog.eu/typescript-react-generic-forward-refs/#option-1%3A-type-assertion\nexport const NestableDraggableFlatList = React.forwardRef(\n NestableDraggableFlatListInner\n) as (\n props: DraggableFlatListProps & { ref?: React.ForwardedRef> }\n) => ReturnType;\n"],"mappings":"mcAAA,qDACA,yCACA,8DAKA,0FACA,yFACA,iEAEA,6D,unCAGA,QAASA,+BAAT,CACEC,KADF,CAEEC,GAFF,CAGE,CACA,GAAMC,sBAAqB,CAAG,GAAAC,aAAA,EAAO,KAAP,CAA9B,CAEA,GAAI,CAACD,qBAAqB,CAACE,OAA3B,CAAoC,CAClCC,mBAAA,CAAOC,UAAP,CAAkB,CAChB,2HADgB,CAAlB,EAIAC,OAAO,CAACC,wBAAR,CAAmC,KAAnC,CACAN,qBAAqB,CAACE,OAAtB,CAAgC,IAAhC,CACD,CAVD,0BAgBI,GAAAK,qEAAA,GAhBJ,CAaEC,aAbF,uBAaEA,aAbF,CAcEC,iBAdF,uBAcEA,iBAdF,CAeEC,qBAfF,uBAeEA,qBAfF,CAkBA,GAAMC,mBAAkB,CAAG,GAAAC,qCAAA,EAAe,CAAf,CAA3B,CAlBA,cAmBgC,GAAAC,eAAA,EAAS,EAAT,CAnBhC,qDAmBOC,QAnBP,eAmBiBC,WAnBjB,eAoBA,GAAMC,mBAAkB,CAAG,GAAAJ,qCAAA,EAAe,CAAf,CAA3B,CApBA,eAqB8C,GAAAC,eAAA,EAASG,kBAAT,CArB9C,sDAqBOC,eArBP,eAqBwBC,kBArBxB,eAuBA,GAAMC,YAAW,CAAG,GAAAC,sCAAA,iCAAsB,CACxC,MAAOH,gBAAe,CAACI,KAAhB,CAAwBV,kBAAkB,CAACU,KAAlD,CACD,CAFmB,8BAtCbJ,eAsCa,oBAtCWN,kBAsCX,iUAEjB,CAACM,eAAD,CAFiB,CAApB,CAIA,GAAAK,wCAAA,mBACKR,QADL,EAEEK,WAAW,CAAXA,WAFF,IAKA,GAAMI,sBAAqB,CAAG,GAAAC,oCAAA,sDAAkB,eAA4B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,CAAE,KAJjB,EAKMxC,KALN,EAME,iBAAiB,CAAEW,iBANrB,CAOE,WAAW,CAAEyB,WAPf,CAQE,SAAS,CAAEE,SARb,CASE,aAAa,CAAEC,aATjB,6EADF,CAaD,CAIM,GAAME,0BAAyB,CAAGC,cAAA,CAAMC,UAAN,CACvC5C,8BADuC,CAAlC,C"} \ No newline at end of file diff --git a/lib/commonjs/components/NestableScrollContainer.js b/lib/commonjs/components/NestableScrollContainer.js index 0f35681e..55933890 100644 --- a/lib/commonjs/components/NestableScrollContainer.js +++ b/lib/commonjs/components/NestableScrollContainer.js @@ -15,7 +15,7 @@ var _useKeyboardListener = _interopRequireDefault( require("../hooks/useKeyboardListener") ); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/NestableScrollContainer.tsx", + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/NestableScrollContainer.tsx", _this = this; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; @@ -82,7 +82,7 @@ function NestableScrollContainerInner(props) { "function _f({contentOffset:contentOffset}){const{outerScrollOffset}=jsThis._closure;{outerScrollOffset.value=contentOffset.y;}}"; _f.__workletHash = 1284487457963; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/NestableScrollContainer.tsx (26:14)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/NestableScrollContainer.tsx (26:14)"; return _f; })(), }); diff --git a/lib/commonjs/components/NestableScrollContainer.js.map b/lib/commonjs/components/NestableScrollContainer.js.map index 626abf62..a6c4957f 100644 --- a/lib/commonjs/components/NestableScrollContainer.js.map +++ b/lib/commonjs/components/NestableScrollContainer.js.map @@ -1 +1 @@ -{"version":3,"names":["AnimatedScrollView","Animated","createAnimatedComponent","ScrollView","NestableScrollContainerInner","props","useSafeNestableScrollContainerContext","outerScrollOffset","containerSize","scrollViewSize","scrollableRef","outerScrollEnabled","useKeyboardListener","onScroll","useAnimatedScrollHandler","contentOffset","value","y","onLayout","useStableCallback","event","layout","nativeEvent","height","onContentSizeChange","w","h","NestableScrollContainer","React","forwardRef","forwardedRef","undefined"],"sources":["NestableScrollContainer.tsx"],"sourcesContent":["import React from \"react\";\nimport { LayoutChangeEvent, ScrollViewProps } from \"react-native\";\nimport { ScrollView } from \"react-native-gesture-handler\";\nimport Animated, { useAnimatedScrollHandler } from \"react-native-reanimated\";\nimport {\n NestableScrollContainerProvider,\n useSafeNestableScrollContainerContext,\n} from \"../context/nestableScrollContainerContext\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport useKeyboardListener from \"../hooks/useKeyboardListener\";\n\nconst AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);\n\nfunction NestableScrollContainerInner(props: ScrollViewProps) {\n const {\n outerScrollOffset,\n containerSize,\n scrollViewSize,\n scrollableRef,\n outerScrollEnabled,\n } = useSafeNestableScrollContainerContext();\n\n useKeyboardListener();\n\n const onScroll = useAnimatedScrollHandler({\n onScroll: ({ contentOffset }) => {\n outerScrollOffset.value = contentOffset.y;\n },\n });\n\n const onLayout = useStableCallback((event: LayoutChangeEvent) => {\n const {\n nativeEvent: { layout },\n } = event;\n containerSize.value = layout.height;\n });\n\n const onContentSizeChange = useStableCallback((w: number, h: number) => {\n scrollViewSize.value = h;\n props.onContentSizeChange?.(w, h);\n });\n\n return (\n \n );\n}\n\nexport const NestableScrollContainer = React.forwardRef(\n (props: ScrollViewProps, forwardedRef?: React.ForwardedRef) => {\n return (\n ) || undefined\n }\n >\n \n \n );\n }\n);\n"],"mappings":"mQAAA,oDAEA,uEACA,uFACA,yFAIA,6DACA,yF,knCAEA,GAAMA,mBAAkB,CAAGC,8BAAA,CAASC,uBAAT,CAAiCC,qCAAjC,CAA3B,CAEA,QAASC,6BAAT,CAAsCC,KAAtC,CAA8D,2BAOxD,GAAAC,qEAAA,GAPwD,CAE1DC,iBAF0D,uBAE1DA,iBAF0D,CAG1DC,aAH0D,uBAG1DA,aAH0D,CAI1DC,cAJ0D,uBAI1DA,c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rollView","NestableScrollContainerInner","props","useSafeNestableScrollContainerContext","outerScrollOffset","containerSize","scrollViewSize","scrollableRef","outerScrollEnabled","useKeyboardListener","onScroll","useAnimatedScrollHandler","contentOffset","value","y","onLayout","useStableCallback","event","layout","nativeEvent","height","onContentSizeChange","w","h","NestableScrollContainer","React","forwardRef","forwardedRef","undefined"],"sources":["NestableScrollContainer.tsx"],"sourcesContent":["import React from \"react\";\nimport { LayoutChangeEvent, ScrollViewProps } from \"react-native\";\nimport { ScrollView } from \"react-native-gesture-handler\";\nimport Animated, { useAnimatedScrollHandler } from \"react-native-reanimated\";\nimport {\n NestableScrollContainerProvider,\n useSafeNestableScrollContainerContext,\n} from \"../context/nestableScrollContainerContext\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport useKeyboardListener from \"../hooks/useKeyboardListener\";\n\nconst AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);\n\nfunction NestableScrollContainerInner(props: ScrollViewProps) {\n const {\n outerScrollOffset,\n containerSize,\n scrollViewSize,\n scrollableRef,\n outerScrollEnabled,\n } = useSafeNestableScrollContainerContext();\n\n useKeyboardListener();\n\n const onScroll = useAnimatedScrollHandler({\n onScroll: ({ contentOffset }) => {\n outerScrollOffset.value = contentOffset.y;\n },\n });\n\n const onLayout = useStableCallback((event: LayoutChangeEvent) => {\n const {\n nativeEvent: { layout },\n } = event;\n containerSize.value = layout.height;\n });\n\n const onContentSizeChange = useStableCallback((w: number, h: number) => {\n scrollViewSize.value = h;\n props.onContentSizeChange?.(w, h);\n });\n\n return (\n \n );\n}\n\nexport const NestableScrollContainer = React.forwardRef(\n (props: ScrollViewProps, forwardedRef?: React.ForwardedRef) => {\n return (\n ) || undefined\n }\n >\n \n \n );\n }\n);\n"],"mappings":"mQAAA,oDAEA,uEACA,uFACA,yFAIA,6DACA,yF,goCAEA,GAAMA,mBAAkB,CAAGC,8BAAA,CAASC,uBAAT,CAAiCC,qCAAjC,CAA3B,CAEA,QAASC,6BAAT,CAAsCC,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DC,SAF5D,6EAKE,6BAAC,4BAAD,0BAAkC1B,KAAlC,+EALF,CADF,CASD,CAXoC,CAAhC,C"} \ No newline at end of file diff --git a/lib/commonjs/components/PlaceholderItem.js b/lib/commonjs/components/PlaceholderItem.js index 1fd6c4d6..a842f788 100644 --- a/lib/commonjs/components/PlaceholderItem.js +++ b/lib/commonjs/components/PlaceholderItem.js @@ -14,7 +14,7 @@ var _draggableFlatListContext = require("../context/draggableFlatListContext"); var _refContext = require("../context/refContext"); var _utils = require("../utils"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/PlaceholderItem.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/PlaceholderItem.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); @@ -87,7 +87,7 @@ function PlaceholderItem(_ref) { "function _f(){const{activeCellSize}=jsThis._closure;{return activeCellSize.value;}}"; _f.__workletHash = 8295849844051; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/PlaceholderItem.tsx (32:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/PlaceholderItem.tsx (32:4)"; return _f; })(), (function () { @@ -104,7 +104,7 @@ function PlaceholderItem(_ref) { "function _f(cur,prev){const{runOnJS,setSize}=jsThis._closure;{if(cur!==prev){runOnJS(setSize)(cur);}}}"; _f.__workletHash = 8290012385169; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/PlaceholderItem.tsx (35:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/PlaceholderItem.tsx (35:4)"; return _f; })() ); @@ -141,7 +141,7 @@ function PlaceholderItem(_ref) { "function _f(){const{placeholderOffset,scrollOffset,size,horizontalAnim}=jsThis._closure;{const offset=placeholderOffset.value-scrollOffset.value;return{opacity:size>=0?1:0,overflow:'hidden',transform:[horizontalAnim.value?{translateX:offset}:{translateY:offset}]};}}"; _f.__workletHash = 13197147672694; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/PlaceholderItem.tsx (48:37)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/PlaceholderItem.tsx (48:37)"; _f.__optimalization = 3; return _f; })(), diff --git a/lib/commonjs/components/PlaceholderItem.js.map b/lib/commonjs/components/PlaceholderItem.js.map index 59e8366f..1c9d2d1b 100644 --- a/lib/commonjs/components/PlaceholderItem.js.map +++ b/lib/commonjs/components/PlaceholderItem.js.map @@ -1 +1 @@ -{"version":3,"names":["PlaceholderItem","renderPlaceholder","useState","size","setSize","useAnimatedValues","activeCellSize","placeholderOffset","spacerIndexAnim","horizontalAnim","scrollOffset","useRefs","keyToIndexRef","propsRef","useDraggableFlatListContext","activeKey","horizontal","useAnimatedReaction","value","cur","prev","runOnJS","activeIndex","current","get","undefined","activeItem","data","animStyle","useAnimatedStyle","offset","opacity","overflow","transform","translateX","translateY","extraStyle","useMemo","width","height","StyleSheet","absoluteFill","item","index","typedMemo"],"sources":["PlaceholderItem.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n} from \"react-native-reanimated\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { useRefs } from \"../context/refContext\";\nimport { RenderPlaceholder } from \"../types\";\nimport { typedMemo } from \"../utils\";\n\ntype Props = {\n renderPlaceholder?: RenderPlaceholder;\n};\n\nfunction PlaceholderItem({ renderPlaceholder }: Props) {\n const [size, setSize] = useState(0);\n const {\n activeCellSize,\n placeholderOffset,\n spacerIndexAnim,\n horizontalAnim,\n scrollOffset,\n } = useAnimatedValues();\n const { keyToIndexRef, propsRef } = useRefs();\n const { activeKey, horizontal } = useDraggableFlatListContext();\n\n // Size does not seem to be respected when it is an animated style\n useAnimatedReaction(\n () => {\n return activeCellSize.value;\n },\n (cur, prev) => {\n if (cur !== prev) {\n runOnJS(setSize)(cur);\n }\n }\n );\n\n const activeIndex = activeKey\n ? keyToIndexRef.current.get(activeKey)\n : undefined;\n const activeItem =\n activeIndex === undefined ? null : propsRef.current?.data[activeIndex];\n\n const animStyle = useAnimatedStyle(() => {\n const offset = placeholderOffset.value - scrollOffset.value\n return {\n opacity: size >= 0 ? 1 : 0,\n overflow: 'hidden',\n transform: [\n horizontalAnim.value\n ? { translateX: offset }\n : { translateY: offset },\n ],\n };\n\n }, [spacerIndexAnim, placeholderOffset, horizontalAnim, scrollOffset, size]);\n\n const extraStyle = useMemo(() => {\n return horizontal ? { width: size } : { height: size };\n }, [horizontal, size])\n\n return (\n \n {!activeItem || activeIndex === undefined\n ? null\n : renderPlaceholder?.({ item: activeItem, index: activeIndex })}\n \n );\n}\n\nexport default typedMemo(PlaceholderItem);\n"],"mappings":"+PAAA,qDACA,yCACA,uFAKA,qEACA,6EACA,iDAEA,+B,+lCAMA,QAASA,gBAAT,MAA6D,0BAA/BC,kBAA+B,MAA/BA,iBAA+B,eACnC,GAAAC,eAAA,EAAS,CAAT,CADmC,qDACpDC,IADoD,eAC9CC,OAD8C,sCAQvD,GAAAC,uCAAA,GARuD,CAGzDC,cAHyD,oBAGzDA,cAHyD,CAIzDC,iBAJyD,oBAIzDA,iBAJyD,CAKzDC,eALyD,oBAKzDA,eALyD,CAMzDC,cANyD,oBAMzDA,cANyD,CAOzDC,YAPyD,oBAOzDA,YAPyD,cASvB,GAAAC,mBAAA,GATuB,CASnDC,aATmD,UASnDA,aATmD,CASpCC,QAToC,UASpCA,QAToC,2BAUzB,GAAAC,qDAAA,GAVyB,CAUnDC,SAVmD,uBAUnDA,SAVmD,CAUxCC,UAVwC,uBAUxCA,UAVwC,CAa3D,GAAAC,0CAAA,iCACQ,CACJ,MAAOX,eAAc,CAACY,KAAtB,CACD,CAHH,6BA5BOZ,cA4BP,wRAIGa,GAJH,CAIQC,IAJR,CAIiB,CACb,GAAID,GAAG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AE,CAACyB,uBAAA,CAAWC,YAAZ,CAA0Bb,SAA1B,CAAqCQ,UAArC,CAFT,4EAIG,CAACV,UAAD,EAAeJ,WAAW,GAAKG,SAA/B,CACG,IADH,CAEGxB,iBAFH,cAEGA,iBAAiB,CAAG,CAAEyC,IAAI,CAAEhB,UAAR,CAAoBiB,KAAK,CAAErB,WAA3B,CAAH,CANvB,CADF,CAUD,C,aAEc,GAAAsB,gBAAA,EAAU5C,eAAV,C"} \ No newline at end of file +{"version":3,"names":["PlaceholderItem","renderPlaceholder","useState","size","setSize","useAnimatedValues","activeCellSize","placeholderOffset","spacerIndexAnim","horizontalAnim","scrollOffset","useRefs","keyToIndexRef","propsRef","useDraggableFlatListContext","activeKey","horizontal","useAnimatedReaction","value","cur","prev","runOnJS","activeIndex","current","get","undefined","activeItem","data","animStyle","useAnimatedStyle","offset","opacity","overflow","transform","translateX","translateY","extraStyle","useMemo","width","height","StyleSheet","absoluteFill","item","index","typedMemo"],"sources":["PlaceholderItem.tsx"],"sourcesContent":["import React, { useMemo, useState } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n} from \"react-native-reanimated\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { useRefs } from \"../context/refContext\";\nimport { RenderPlaceholder } from \"../types\";\nimport { typedMemo } from \"../utils\";\n\ntype Props = {\n renderPlaceholder?: RenderPlaceholder;\n};\n\nfunction PlaceholderItem({ renderPlaceholder }: Props) {\n const [size, setSize] = useState(0);\n const {\n activeCellSize,\n placeholderOffset,\n spacerIndexAnim,\n horizontalAnim,\n scrollOffset,\n } = useAnimatedValues();\n const { keyToIndexRef, propsRef } = useRefs();\n const { activeKey, horizontal } = useDraggableFlatListContext();\n\n // Size does not seem to be respected when it is an animated style\n useAnimatedReaction(\n () => {\n return activeCellSize.value;\n },\n (cur, prev) => {\n if (cur !== prev) {\n runOnJS(setSize)(cur);\n }\n }\n );\n\n const activeIndex = activeKey\n ? keyToIndexRef.current.get(activeKey)\n : undefined;\n const activeItem =\n activeIndex === undefined ? null : propsRef.current?.data[activeIndex];\n\n const animStyle = useAnimatedStyle(() => {\n const offset = placeholderOffset.value - scrollOffset.value\n return {\n opacity: size >= 0 ? 1 : 0,\n overflow: 'hidden',\n transform: [\n horizontalAnim.value\n ? { translateX: offset }\n : { translateY: offset },\n ],\n };\n\n }, [spacerIndexAnim, placeholderOffset, horizontalAnim, scrollOffset, size]);\n\n const extraStyle = useMemo(() => {\n return horizontal ? { width: size } : { height: size };\n }, [horizontal, size])\n\n return (\n \n {!activeItem || activeIndex === undefined\n ? null\n : renderPlaceholder?.({ item: activeItem, index: activeIndex })}\n \n );\n}\n\nexport default typedMemo(PlaceholderItem);\n"],"mappings":"+PAAA,qDACA,yCACA,uFAKA,qEACA,6EACA,iDAEA,+B,6mCAMA,QAASA,gBAAT,MAA6D,0BAA/BC,kBAA+B,MAA/BA,iBAA+B,eACnC,GAAAC,eAAA,EAAS,CAAT,CADmC,qDACpDC,IADoD,eAC9CC,OAD8C,sCAQvD,GAAAC,uCAAA,GARuD,CAGzDC,cAHyD,oBAGzDA,cAHyD,CAIzDC,iBAJyD,oBAIzDA,iBAJyD,CAKzDC,eALyD,oBAKzDA,eALyD,CAMzDC,cANyD,oBAMzDA,cANyD,CAOzDC,YAPyD,oBAOzDA,YAPyD,cASvB,GAAAC,mBAAA,GATuB,CASnDC,aATmD,UASnDA,aATmD,CASpCC,QAToC,UASpCA,QAToC,2BAUzB,GAAAC,qDAAA,GAVyB,CAUnDC,SAVmD,uBAUnDA,SAVmD,CAUxCC,UAVwC,uBAUxCA,UAVwC,CAa3D,GAAAC,0CAAA,iCACQ,CACJ,MAAOX,eAAc,CAACY,KAAtB,CACD,CAHH,6BA5BOZ,cA4BP,sSAIGa,GAJH,CAIQC,IAJR,CAIiB,CACb,GAAID,GAAG,GAAKC,IAAZ,CAAkB,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,YAAZ,CAA0Bb,SAA1B,CAAqCQ,UAArC,CAFT,4EAIG,CAACV,UAAD,EAAeJ,WAAW,GAAKG,SAA/B,CACG,IADH,CAEGxB,iBAFH,cAEGA,iBAAiB,CAAG,CAAEyC,IAAI,CAAEhB,UAAR,CAAoBiB,KAAK,CAAErB,WAA3B,CAAH,CANvB,CADF,CAUD,C,aAEc,GAAAsB,gBAAA,EAAU5C,eAAV,C"} \ No newline at end of file diff --git a/lib/commonjs/components/RowItem.js b/lib/commonjs/components/RowItem.js index 7833d3d7..f4ca5edb 100644 --- a/lib/commonjs/components/RowItem.js +++ b/lib/commonjs/components/RowItem.js @@ -12,7 +12,7 @@ var _utils = require("../utils"); var _reactNativeGestureHandler = require("react-native-gesture-handler"); var _reactNativeReanimated = require("react-native-reanimated"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/RowItem.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/RowItem.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); @@ -100,7 +100,7 @@ function RowItem(props) { "function _f(){const{enabled,runOnJS,drag}=jsThis._closure;{enabled.value=true;runOnJS(drag)();}}"; _f.__workletHash = 8335102146761; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/RowItem.tsx (45:19)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/RowItem.tsx (45:19)"; return _f; })() ) @@ -114,7 +114,7 @@ function RowItem(props) { "function _f(){const{enabled}=jsThis._closure;{enabled.value=false;}}"; _f.__workletHash = 9465620530585; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/RowItem.tsx (49:17)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/RowItem.tsx (49:17)"; return _f; })() ) diff --git a/lib/commonjs/components/RowItem.js.map b/lib/commonjs/components/RowItem.js.map index ca057df5..78c90e5b 100644 --- a/lib/commonjs/components/RowItem.js.map +++ b/lib/commonjs/components/RowItem.js.map @@ -1 +1 @@ -{"version":3,"names":["RowItem","props","propsRef","useRef","current","useDraggableFlatListContext","activeKey","activeKeyRef","useRefs","keyToIndexRef","drag","useStableCallback","itemKey","debug","console","log","renderItem","item","panGesture","enabled","extraData","tapGesture","Gesture","Tap","onTouchesDown","value","runOnJS","onTouchesUp","simultaneousWithExternalGesture","getIndex","get","typedMemo","Inner","rest","MemoizedInner"],"sources":["RowItem.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { useRefs } from \"../context/refContext\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport { RenderItem } from \"../types\";\nimport { typedMemo } from \"../utils\";\nimport { Gesture, PanGesture, TapGesture } from \"react-native-gesture-handler\";\nimport { SharedValue, runOnJS } from \"react-native-reanimated\";\n\ntype Props = {\n extraData?: any;\n drag: (itemKey: string) => void;\n enabled: SharedValue;\n item: T;\n renderItem: RenderItem;\n itemKey: string;\n panGesture: PanGesture;\n debug?: boolean;\n};\n\nfunction RowItem(props: Props) {\n const propsRef = useRef(props);\n propsRef.current = props;\n\n const { activeKey } = useDraggableFlatListContext();\n const activeKeyRef = useRef(activeKey);\n activeKeyRef.current = activeKey;\n const { keyToIndexRef } = useRefs();\n\n const drag = useStableCallback(() => {\n const { drag, itemKey, debug } = propsRef.current;\n if (activeKeyRef.current) {\n // already dragging an item, noop\n if (debug)\n console.log(\n \"## attempt to drag item while another item is already active, noop\"\n );\n }\n drag(itemKey);\n });\n\n const { renderItem, item, itemKey, panGesture, enabled, extraData } = props;\n\n const tapGesture = Gesture.Tap()\n .onTouchesDown(() => {\n enabled.value = true;\n runOnJS(drag)();\n })\n .onTouchesUp(() => {\n enabled.value = false;\n })\n .simultaneousWithExternalGesture(panGesture);\n\n const getIndex = useStableCallback(() => {\n return keyToIndexRef.current.get(itemKey);\n });\n\n return (\n \n );\n}\n\nexport default typedMemo(RowItem);\n\ntype InnerProps = {\n isActive: boolean;\n item: T;\n getIndex: () => number | undefined;\n renderItem: RenderItem;\n tapGesture: TapGesture;\n extraData?: any;\n};\n\nfunction Inner({ renderItem, extraData, ...rest }: InnerProps) {\n return renderItem({ ...rest }) as JSX.Element;\n}\n\nconst MemoizedInner = typedMemo(Inner);\n"],"mappings":"mRAAA,qDACA,6EACA,iDACA,6DAEA,+BACA,uEACA,8D,ulCAaA,QAASA,QAAT,CAAoBC,KAApB,CAAqC,CACnC,GAAMC,SAAQ,CAAG,GAAAC,aAAA,EAAOF,KAAP,CAAjB,CACAC,QAAQ,CAACE,OAAT,CAAmBH,KAAnB,CAFmC,0BAIb,GAAAI,qDAAA,GAJa,CAI3BC,SAJ2B,uBAI3BA,SAJ2B,CAKnC,GAAMC,aAAY,CAAG,GAAAJ,aAAA,EAAOG,SAAP,CAArB,CACAC,YAAY,CAACH,OAAb,CAAuBE,SAAvB,CANmC,aAOT,GAAAE,mBAAA,GAPS,CAO3BC,aAP2B,UAO3BA,aAP2B,CASnC,GAAMC,KAAI,CAAG,GAAAC,oCAAA,EAAkB,UAAM,uBACFT,QAAQ,CAACE,OADP,CAC3BM,IAD2B,mBAC3BA,IAD2B,CACrBE,OADqB,mBACrBA,OADqB,CACZC,KADY,mBACZA,KADY,CAEnC,GAAIN,YAAY,CAACH,OAAjB,CAA0B,CAExB,GAAIS,KAAJ,CACEC,OAAO,CAACC,GAAR,CACE,oEADF,EAGH,CACDL,IAAI,CAACE,OAAD,CAAJ,CACD,CAVY,CAAb,CATmC,GAqB3BI,WArB2B,CAqBmCf,KArBnC,CAqB3Be,UArB2B,CAqBfC,IArBe,CAqBmChB,KArBnC,CAqBfgB,IArBe,CAqBTL,OArBS,CAqBmCX,KArBnC,CAqBTW,OArBS,CAqBAM,UArBA,CAqBmCjB,KArBnC,CAqBAiB,UArBA,CAqBYC,OArBZ,CAqBmClB,KArBnC,CAqBYkB,OArBZ,CAqBqBC,SArBrB,CAqBmCnB,KArBnC,CAqBqBmB,SArBrB,CAuBnC,GAAMC,WAAU,CAAGC,kCAAA,CAAQC,GAAR,GAChBC,aADgB,gCACI,CACnBL,OAAO,CAACM,KAAR,CAAgB,IAAhB,CACA,GAAAC,8BAAA,EAAQhB,IAAR,IACD,CAJgB,sBAzCnBS,OAyCmB,SAxCnBO,8BAwCmB,MAxCXhB,IAwCW,iQAKhBiB,WALgB,gCAKE,CACjBR,OAAO,CAACM,KAAR,CAAgB,KAAhB,CACD,CAPgB,sBAzCnBN,OAyCmB,qOAQhBS,+BARgB,CAQgBV,UARhB,CAAnB,CAUA,GAAMW,SAAQ,CAAG,GAAAlB,oCAAA,EAAkB,UAAM,CACvC,MAAOF,cAAa,CAACL,OAAd,CAAsB0B,GAAtB,CAA0BlB,OAA1B,CAAP,CACD,CAFgB,CAAjB,CAIA,MACE,8BAAC,aAAD,EACE,QAAQ,CAAEN,SAAS,GAAKM,OAD1B,CAEE,UAAU,CAAEI,UAFd,CAGE,IAAI,CAAEC,IAHR,CAIE,QAAQ,CAAEY,QAJZ,CAKE,UAAU,CAAER,UALd,CAME,SAAS,CAAED,SANb,4EADF,CAUD,C,aAEc,GAAAW,gBAAA,EAAU/B,OAAV,C,0BAWf,QAASgC,MAAT,MAAqE,IAAjDhB,WAAiD,MAAjDA,UAAiD,CAArCI,SAAqC,MAArCA,SAAqC,CAAvBa,IAAuB,wEACnE,MAAOjB,WAAU,kBAAMiB,IAAN,EAAjB,CACD,CAED,GAAMC,cAAa,CAAG,GAAAH,gBAAA,EAAUC,KAAV,CAAtB"} \ No newline at end of file +{"version":3,"names":["RowItem","props","propsRef","useRef","current","useDraggableFlatListContext","activeKey","activeKeyRef","useRefs","keyToIndexRef","drag","useStableCallback","itemKey","debug","console","log","renderItem","item","panGesture","enabled","extraData","tapGesture","Gesture","Tap","onTouchesDown","value","runOnJS","onTouchesUp","simultaneousWithExternalGesture","getIndex","get","typedMemo","Inner","rest","MemoizedInner"],"sources":["RowItem.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { useRefs } from \"../context/refContext\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport { RenderItem } from \"../types\";\nimport { typedMemo } from \"../utils\";\nimport { Gesture, PanGesture, TapGesture } from \"react-native-gesture-handler\";\nimport { SharedValue, runOnJS } from \"react-native-reanimated\";\n\ntype Props = {\n extraData?: any;\n drag: (itemKey: string) => void;\n enabled: SharedValue;\n item: T;\n renderItem: RenderItem;\n itemKey: string;\n panGesture: PanGesture;\n debug?: boolean;\n};\n\nfunction RowItem(props: Props) {\n const propsRef = useRef(props);\n propsRef.current = props;\n\n const { activeKey } = useDraggableFlatListContext();\n const activeKeyRef = useRef(activeKey);\n activeKeyRef.current = activeKey;\n const { keyToIndexRef } = useRefs();\n\n const drag = useStableCallback(() => {\n const { drag, itemKey, debug } = propsRef.current;\n if (activeKeyRef.current) {\n // already dragging an item, noop\n if (debug)\n console.log(\n \"## attempt to drag item while another item is already active, noop\"\n );\n }\n drag(itemKey);\n });\n\n const { renderItem, item, itemKey, panGesture, enabled, extraData } = props;\n\n const tapGesture = Gesture.Tap()\n .onTouchesDown(() => {\n enabled.value = true;\n runOnJS(drag)();\n })\n .onTouchesUp(() => {\n enabled.value = false;\n })\n .simultaneousWithExternalGesture(panGesture);\n\n const getIndex = useStableCallback(() => {\n return keyToIndexRef.current.get(itemKey);\n });\n\n return (\n \n );\n}\n\nexport default typedMemo(RowItem);\n\ntype InnerProps = {\n isActive: boolean;\n item: T;\n getIndex: () => number | undefined;\n renderItem: RenderItem;\n tapGesture: TapGesture;\n extraData?: any;\n};\n\nfunction Inner({ renderItem, extraData, ...rest }: InnerProps) {\n return renderItem({ ...rest }) as JSX.Element;\n}\n\nconst MemoizedInner = typedMemo(Inner);\n"],"mappings":"mRAAA,qDACA,6EACA,iDACA,6DAEA,+BACA,uEACA,8D,qmCAaA,QAASA,QAAT,CAAoBC,KAApB,CAAqC,CACnC,GAAMC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yCmB,mPAQhBS,+BARgB,CAQgBV,UARhB,CAAnB,CAUA,GAAMW,SAAQ,CAAG,GAAAlB,oCAAA,EAAkB,UAAM,CACvC,MAAOF,cAAa,CAACL,OAAd,CAAsB0B,GAAtB,CAA0BlB,OAA1B,CAAP,CACD,CAFgB,CAAjB,CAIA,MACE,8BAAC,aAAD,EACE,QAAQ,CAAEN,SAAS,GAAKM,OAD1B,CAEE,UAAU,CAAEI,UAFd,CAGE,IAAI,CAAEC,IAHR,CAIE,QAAQ,CAAEY,QAJZ,CAKE,UAAU,CAAER,UALd,CAME,SAAS,CAAED,SANb,4EADF,CAUD,C,aAEc,GAAAW,gBAAA,EAAU/B,OAAV,C,0BAWf,QAASgC,MAAT,MAAqE,IAAjDhB,WAAiD,MAAjDA,UAAiD,CAArCI,SAAqC,MAArCA,SAAqC,CAAvBa,IAAuB,wEACnE,MAAOjB,WAAU,kBAAMiB,IAAN,EAAjB,CACD,CAED,GAAMC,cAAa,CAAG,GAAAH,gBAAA,EAAUC,KAAV,CAAtB"} \ No newline at end of file diff --git a/lib/commonjs/components/ScrollOffsetListener.js b/lib/commonjs/components/ScrollOffsetListener.js index d501a4a0..066d5fc2 100644 --- a/lib/commonjs/components/ScrollOffsetListener.js +++ b/lib/commonjs/components/ScrollOffsetListener.js @@ -15,7 +15,7 @@ var ScrollOffsetListener = function ScrollOffsetListener(_ref) { "function _f(){const{scrollOffset}=jsThis._closure;{return scrollOffset.value;}}"; _f.__workletHash = 14236293224915; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/ScrollOffsetListener.tsx (14:22)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/ScrollOffsetListener.tsx (14:22)"; return _f; })(), (function () { @@ -32,7 +32,7 @@ var ScrollOffsetListener = function ScrollOffsetListener(_ref) { "function _f(cur,prev){const{runOnJS,onScrollOffsetChange}=jsThis._closure;{if(cur!==prev){runOnJS(onScrollOffsetChange)(cur);}}}"; _f.__workletHash = 2670088941649; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/components/ScrollOffsetListener.tsx (16:5)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/components/ScrollOffsetListener.tsx (16:5)"; return _f; })(), [scrollOffset] diff --git a/lib/commonjs/components/ScrollOffsetListener.js.map b/lib/commonjs/components/ScrollOffsetListener.js.map index 4af51f8f..7a7469e9 100644 --- a/lib/commonjs/components/ScrollOffsetListener.js.map +++ b/lib/commonjs/components/ScrollOffsetListener.js.map @@ -1 +1 @@ -{"version":3,"names":["ScrollOffsetListener","scrollOffset","onScrollOffsetChange","useAnimatedReaction","value","cur","prev","runOnJS","typedMemo"],"sources":["ScrollOffsetListener.tsx"],"sourcesContent":["import Animated, { runOnJS, useAnimatedReaction } from \"react-native-reanimated\";\nimport { typedMemo } from \"../utils\";\n\ntype Props = {\n scrollOffset: Animated.SharedValue;\n onScrollOffsetChange: (offset: number) => void;\n};\n\nconst ScrollOffsetListener = ({\n scrollOffset,\n onScrollOffsetChange,\n}: Props) => {\n\n useAnimatedReaction(() => {\n return scrollOffset.value\n }, (cur, prev) => {\n if (cur !== prev) {\n runOnJS(onScrollOffsetChange)(cur)\n }\n }, [scrollOffset])\n\n return null;\n};\n\nexport default typedMemo(ScrollOffsetListener);\n"],"mappings":"gFAAA,8DACA,+BAOA,GAAMA,qBAAoB,CAAG,QAAvBA,qBAAuB,MAGhB,IAFXC,aAEW,MAFXA,YAEW,CADXC,oBACW,MADXA,oBACW,CAEX,GAAAC,0CAAA,iCAA0B,CACxB,MAAOF,aAAY,CAACG,KAApB,CACD,CAFD,2BAXOH,YAWP,2RAEII,GAFJ,CAESC,IAFT,CAEkB,CAChB,GAAID,GAAG,GAAKC,IAAZ,CAAkB,CAChB,GAAAC,8BAAA,EAAQL,oBAAR,EAA8BG,GAA9B,EACD,CACF,CAND,sBAVEE,8BAUF,sBAVUL,oBAUV,4SAMG,CAACD,YAAD,CANH,EAQA,MAAO,KAAP,CACD,CAdD,C,aAgBe,GAAAO,gBAAA,EAAUR,oBAAV,C"} \ No newline at end of file +{"version":3,"names":["ScrollOffsetListener","scrollOffset","onScrollOffsetChange","useAnimatedReaction","value","cur","prev","runOnJS","typedMemo"],"sources":["ScrollOffsetListener.tsx"],"sourcesContent":["import Animated, { runOnJS, useAnimatedReaction } from \"react-native-reanimated\";\nimport { typedMemo } from \"../utils\";\n\ntype Props = {\n scrollOffset: Animated.SharedValue;\n onScrollOffsetChange: (offset: number) => void;\n};\n\nconst ScrollOffsetListener = ({\n scrollOffset,\n onScrollOffsetChange,\n}: Props) => {\n\n useAnimatedReaction(() => {\n return scrollOffset.value\n }, (cur, prev) => {\n if (cur !== prev) {\n runOnJS(onScrollOffsetChange)(cur)\n }\n }, [scrollOffset])\n\n return null;\n};\n\nexport default typedMemo(ScrollOffsetListener);\n"],"mappings":"gFAAA,8DACA,+BAOA,GAAMA,qBAAoB,CAAG,QAAvBA,qBAAuB,MAGhB,IAFXC,aAEW,MAFXA,YAEW,CADXC,oBACW,MADXA,oBACW,CAEX,GAAAC,0CAAA,iCAA0B,CACxB,MAAOF,aAAY,CAACG,KAApB,CACD,CAFD,2BAXOH,YAWP,ySAEII,GAFJ,CAESC,IAFT,CAEkB,CAChB,GAAID,GAAG,GAAKC,IAAZ,CAAkB,CAChB,GAAAC,8BAAA,EAAQL,oBAAR,EAA8BG,GAA9B,EACD,CACF,CAND,sBAVEE,8BAUF,sBAVUL,oBAUV,0TAMG,CAACD,YAAD,CANH,EAQA,MAAO,KAAP,CACD,CAdD,C,aAgBe,GAAAO,gBAAA,EAAUR,oBAAV,C"} \ No newline at end of file diff --git a/lib/commonjs/context/animatedValueContext.js b/lib/commonjs/context/animatedValueContext.js index 363ae05c..89b0d24a 100644 --- a/lib/commonjs/context/animatedValueContext.js +++ b/lib/commonjs/context/animatedValueContext.js @@ -6,7 +6,7 @@ var _reactNativeReanimated = require("react-native-reanimated"); var _reactNativeGestureHandler = require("react-native-gesture-handler"); var _propsContext = require("./propsContext"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); @@ -107,7 +107,7 @@ function useSetupAnimatedValues() { "function _f(){const{activeIndexAnim}=jsThis._closure;{return activeIndexAnim.value;}}"; _f.__workletHash = 1662895275731; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (74:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (74:4)"; return _f; })(), (function () { @@ -127,7 +127,7 @@ function useSetupAnimatedValues() { "function _f(cur,prev){const{scrollInit,scrollOffset,outerScrollInit,outerScrollOffset}=jsThis._closure;{if(cur!==prev&&cur>=0){scrollInit.value=scrollOffset.value;outerScrollInit.value=outerScrollOffset.value;}}}"; _f.__workletHash = 14917928217945; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (77:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (77:4)"; return _f; })(), [outerScrollOffset] @@ -146,7 +146,7 @@ function useSetupAnimatedValues() { "function _f(){const{isTouchActiveNative,activeIndexAnim}=jsThis._closure;{return isTouchActiveNative.value&&activeIndexAnim.value>=0;}}"; _f.__workletHash = 15157110606697; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (88:41)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (88:41)"; return _f; })(), [] @@ -171,7 +171,7 @@ function useSetupAnimatedValues() { "function _f(){const{isDraggingCell,scrollOffset,scrollInit,outerScrollOffset,outerScrollInit}=jsThis._closure;{if(!isDraggingCell.value)return 0;const innerScrollDiff=scrollOffset.value-scrollInit.value;const outerScrollDiff=outerScrollOffset.value-outerScrollInit.value;const scrollDiff=innerScrollDiff+outerScrollDiff;return scrollDiff;}}"; _f.__workletHash = 15552139107413; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (92:45)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (92:45)"; return _f; })(), [] @@ -193,7 +193,7 @@ function useSetupAnimatedValues() { "function _f(){const{isTouchActiveNative,autoScrollDistance,touchTranslate}=jsThis._closure;{const extraTranslate=isTouchActiveNative.value?autoScrollDistance.value:0;return touchTranslate.value+extraTranslate;}}"; _f.__workletHash = 6038336113742; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (101:44)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (101:44)"; return _f; })(), [] @@ -235,7 +235,7 @@ function useSetupAnimatedValues() { "function _f(){const{containerSize,activeCellSize,scrollOffset,touchPositionDiff,activeCellOffset,scrollViewSize,isTouchActiveNative}=jsThis._closure;{const containerMinusActiveCell=containerSize.value-activeCellSize.value+scrollOffset.value;const offsetRelativeToScrollTop=touchPositionDiff.value+activeCellOffset.value;const constrained=Math.min(containerMinusActiveCell,Math.max(scrollOffset.value,offsetRelativeToScrollTop));const maxTranslateNegative=-activeCellOffset.value;const maxTranslatePositive=scrollViewSize.value-(activeCellOffset.value+activeCellSize.value);const constrainedBase=isTouchActiveNative.value?constrained-activeCellOffset.value:touchPositionDiff.value;return Math.min(Math.max(constrainedBase,maxTranslateNegative),maxTranslatePositive);}}"; _f.__workletHash = 12403615032773; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (108:55)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (108:55)"; return _f; })(), [] @@ -258,7 +258,7 @@ function useSetupAnimatedValues() { "function _f(){const{activeIndexAnim,props,touchPositionDiff,touchPositionDiffConstrained}=jsThis._closure;{if(activeIndexAnim.value<0)return 0;return props.dragItemOverflow?touchPositionDiff.value:touchPositionDiffConstrained.value;}}"; _f.__workletHash = 4766979967758; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (136:36)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (136:36)"; return _f; })(), [] @@ -276,7 +276,7 @@ function useSetupAnimatedValues() { "function _f(){const{hoverAnim,activeCellOffset}=jsThis._closure;{return hoverAnim.value+activeCellOffset.value;}}"; _f.__workletHash = 13741556660209; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (143:38)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (143:38)"; return _f; })(), [hoverAnim, activeCellOffset] @@ -297,7 +297,7 @@ function useSetupAnimatedValues() { "function _f(){const{activeIndexAnim,spacerIndexAnim}=jsThis._closure;{const isHovering=activeIndexAnim.value>=0;if(!isHovering&&spacerIndexAnim.value>=0){spacerIndexAnim.value=-1;}}}"; _f.__workletHash = 11056248743165; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (147:18)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/animatedValueContext.tsx (147:18)"; return _f; })(), [] diff --git a/lib/commonjs/context/animatedValueContext.js.map b/lib/commonjs/context/animatedValueContext.js.map index 53f6a0bf..17d046cb 100644 --- a/lib/commonjs/context/animatedValueContext.js.map +++ b/lib/commonjs/context/animatedValueContext.js.map @@ -1 +1 @@ -{"version":3,"names":["AnimatedValueContext","React","createContext","undefined","AnimatedValueProvider","children","value","useSetupAnimatedValues","useAnimatedValues","useContext","Error","props","useProps","DEFAULT_VAL","useSharedValue","containerSize","scrollViewSize","panGestureState","GestureState","UNDETERMINED","touchTranslate","isTouchActiveNative","hasMoved","disabled","horizontalAnim","horizontal","activeIndexAnim","spacerIndexAnim","activeCellSize","activeCellOffset","scrollOffset","scrollInit","viewableIndexMin","viewableIndexMax","outerScrollOffset","outerScrollInit","useAnimatedReaction","cur","prev","placeholderOffset","isDraggingCell","useDerivedValue","autoScrollDistance","innerScrollDiff","outerScrollDiff","scrollDiff","touchPositionDiff","extraTranslate","touchPositionDiffConstrained","containerMinusActiveCell","offsetRelativeToScrollTop","constrained","Math","min","max","maxTranslateNegative","maxTranslatePositive","constrainedBase","hoverAnim","dragItemOverflow","hoverOffset","isHovering","resetTouchedCell","useCallback","useMemo","useEffect","onAnimValInit"],"sources":["animatedValueContext.tsx"],"sourcesContent":["import React, { useMemo, useEffect, useCallback, useContext } from \"react\";\nimport {\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { State as GestureState } from \"react-native-gesture-handler\";\nimport { useProps } from \"./propsContext\";\n\nconst AnimatedValueContext = React.createContext<\n ReturnType | undefined\n>(undefined);\n\nexport default function AnimatedValueProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const value = useSetupAnimatedValues();\n return (\n \n {children}\n \n );\n}\n\nexport function useAnimatedValues() {\n const value = useContext(AnimatedValueContext);\n if (!value) {\n throw new Error(\n \"useAnimatedValues must be called from within AnimatedValueProvider!\"\n );\n }\n return value;\n}\n\nfunction useSetupAnimatedValues() {\n const props = useProps();\n\n const DEFAULT_VAL = useSharedValue(0);\n\n const containerSize = useSharedValue(0);\n const scrollViewSize = useSharedValue(0);\n\n const panGestureState = useSharedValue(\n GestureState.UNDETERMINED\n );\n const touchTranslate = useSharedValue(0);\n\n const isTouchActiveNative = useSharedValue(false);\n\n const hasMoved = useSharedValue(0);\n const disabled = useSharedValue(false);\n\n const horizontalAnim = useSharedValue(!!props.horizontal);\n\n const activeIndexAnim = useSharedValue(-1); // Index of hovering cell\n const spacerIndexAnim = useSharedValue(-1); // Index of hovered-over cell\n\n const activeCellSize = useSharedValue(0); // Height or width of acctive cell\n const activeCellOffset = useSharedValue(0); // Distance between active cell and edge of container\n\n const scrollOffset = useSharedValue(0);\n const scrollInit = useSharedValue(0);\n\n const viewableIndexMin = useSharedValue(0);\n const viewableIndexMax = useSharedValue(0);\n\n // If list is nested there may be an outer scrollview\n const outerScrollOffset = props.outerScrollOffset || DEFAULT_VAL;\n const outerScrollInit = useSharedValue(0);\n\n useAnimatedReaction(\n () => {\n return activeIndexAnim.value;\n },\n (cur, prev) => {\n if (cur !== prev && cur >= 0) {\n scrollInit.value = scrollOffset.value;\n outerScrollInit.value = outerScrollOffset.value;\n }\n },\n [outerScrollOffset]\n );\n\n const placeholderOffset = useSharedValue(0);\n\n const isDraggingCell = useDerivedValue(() => {\n return isTouchActiveNative.value && activeIndexAnim.value >= 0;\n }, []);\n\n const autoScrollDistance = useDerivedValue(() => {\n if (!isDraggingCell.value) return 0;\n const innerScrollDiff = scrollOffset.value - scrollInit.value;\n // If list is nested there may be an outer scroll diff\n const outerScrollDiff = outerScrollOffset.value - outerScrollInit.value;\n const scrollDiff = innerScrollDiff + outerScrollDiff;\n return scrollDiff;\n }, []);\n\n const touchPositionDiff = useDerivedValue(() => {\n const extraTranslate = isTouchActiveNative.value\n ? autoScrollDistance.value\n : 0;\n return touchTranslate.value + extraTranslate;\n }, []);\n\n const touchPositionDiffConstrained = useDerivedValue(() => {\n const containerMinusActiveCell =\n containerSize.value - activeCellSize.value + scrollOffset.value;\n\n const offsetRelativeToScrollTop =\n touchPositionDiff.value + activeCellOffset.value;\n const constrained = Math.min(\n containerMinusActiveCell,\n Math.max(scrollOffset.value, offsetRelativeToScrollTop)\n );\n\n const maxTranslateNegative = -activeCellOffset.value;\n const maxTranslatePositive =\n scrollViewSize.value - (activeCellOffset.value + activeCellSize.value);\n\n // Only constrain the touch position while the finger is on the screen. This allows the active cell\n // to snap above/below the fold once let go, if the drag ends at the top/bottom of the screen.\n const constrainedBase = isTouchActiveNative.value\n ? constrained - activeCellOffset.value\n : touchPositionDiff.value;\n\n // Make sure item is constrained to the boundaries of the scrollview\n return Math.min(\n Math.max(constrainedBase, maxTranslateNegative),\n maxTranslatePositive\n );\n }, []);\n\n const hoverAnim = useDerivedValue(() => {\n if (activeIndexAnim.value < 0) return 0;\n return props.dragItemOverflow\n ? touchPositionDiff.value\n : touchPositionDiffConstrained.value;\n }, []);\n\n const hoverOffset = useDerivedValue(() => {\n return hoverAnim.value + activeCellOffset.value;\n }, [hoverAnim, activeCellOffset]);\n\n useDerivedValue(() => {\n // Reset spacer index when we stop hovering\n const isHovering = activeIndexAnim.value >= 0;\n if (!isHovering && spacerIndexAnim.value >= 0) {\n spacerIndexAnim.value = -1;\n }\n }, []);\n\n // Note: this could use a refactor as it combines touch state + cell animation\n const resetTouchedCell = useCallback(() => {\n activeCellOffset.value = 0;\n hasMoved.value = 0;\n }, []);\n\n const value = useMemo(\n () => ({\n activeCellOffset,\n activeCellSize,\n activeIndexAnim,\n containerSize,\n disabled,\n horizontalAnim,\n hoverAnim,\n hoverOffset,\n isDraggingCell,\n isTouchActiveNative,\n panGestureState,\n placeholderOffset,\n resetTouchedCell,\n scrollOffset,\n scrollViewSize,\n spacerIndexAnim,\n touchPositionDiff,\n touchTranslate,\n autoScrollDistance,\n viewableIndexMin,\n viewableIndexMax,\n }),\n [\n activeCellOffset,\n activeCellSize,\n activeIndexAnim,\n containerSize,\n disabled,\n horizontalAnim,\n hoverAnim,\n hoverOffset,\n isDraggingCell,\n isTouchActiveNative,\n panGestureState,\n placeholderOffset,\n resetTouchedCell,\n scrollOffset,\n scrollViewSize,\n spacerIndexAnim,\n touchPositionDiff,\n touchTranslate,\n autoScrollDistance,\n viewableIndexMin,\n viewableIndexMax,\n ]\n );\n\n useEffect(() => {\n props.onAnimValInit?.(value);\n }, [value]);\n\n return value;\n}\n"],"mappings":"2IAAA,qDACA,8DAKA,uEACA,4C,imCAEA,GAAMA,qBAAoB,CAAGC,cAAA,CAAMC,aAAN,CAE3BC,SAF2B,CAA7B,CAIe,QAASC,sBAAT,MAIZ,IAHDC,SAGC,MAHDA,QAGC,CACD,GAAMC,M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["AnimatedValueContext","React","createContext","undefined","AnimatedValueProvider","children","value","useSetupAnimatedValues","useAnimatedValues","useContext","Error","props","useProps","DEFAULT_VAL","useSharedValue","containerSize","scrollViewSize","panGestureState","GestureState","UNDETERMINED","touchTranslate","isTouchActiveNative","hasMoved","disabled","horizontalAnim","horizontal","activeIndexAnim","spacerIndexAnim","activeCellSize","activeCellOffset","scrollOffset","scrollInit","viewableIndexMin","viewableIndexMax","outerScrollOffset","outerScrollInit","useAnimatedReaction","cur","prev","placeholderOffset","isDraggingCell","useDerivedValue","autoScrollDistance","innerScrollDiff","outerScrollDiff","scrollDiff","touchPositionDiff","extraTranslate","touchPositionDiffConstrained","containerMinusActiveCell","offsetRelativeToScrollTop","constrained","Math","min","max","maxTranslateNegative","maxTranslatePositive","constrainedBase","hoverAnim","dragItemOverflow","hoverOffset","isHovering","resetTouchedCell","useCallback","useMemo","useEffect","onAnimValInit"],"sources":["animatedValueContext.tsx"],"sourcesContent":["import React, { useMemo, useEffect, useCallback, useContext } from \"react\";\nimport {\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { State as GestureState } from \"react-native-gesture-handler\";\nimport { useProps } from \"./propsContext\";\n\nconst AnimatedValueContext = React.createContext<\n ReturnType | undefined\n>(undefined);\n\nexport default function AnimatedValueProvider({\n children,\n}: {\n children: React.ReactNode;\n}) {\n const value = useSetupAnimatedValues();\n return (\n \n {children}\n \n );\n}\n\nexport function useAnimatedValues() {\n const value = useContext(AnimatedValueContext);\n if (!value) {\n throw new Error(\n \"useAnimatedValues must be called from within AnimatedValueProvider!\"\n );\n }\n return value;\n}\n\nfunction useSetupAnimatedValues() {\n const props = useProps();\n\n const DEFAULT_VAL = useSharedValue(0);\n\n const containerSize = useSharedValue(0);\n const scrollViewSize = useSharedValue(0);\n\n const panGestureState = useSharedValue(\n GestureState.UNDETERMINED\n );\n const touchTranslate = useSharedValue(0);\n\n const isTouchActiveNative = useSharedValue(false);\n\n const hasMoved = useSharedValue(0);\n const disabled = useSharedValue(false);\n\n const horizontalAnim = useSharedValue(!!props.horizontal);\n\n const activeIndexAnim = useSharedValue(-1); // Index of hovering cell\n const spacerIndexAnim = useSharedValue(-1); // Index of hovered-over cell\n\n const activeCellSize = useSharedValue(0); // Height or width of acctive cell\n const activeCellOffset = useSharedValue(0); // Distance between active cell and edge of container\n\n const scrollOffset = useSharedValue(0);\n const scrollInit = useSharedValue(0);\n\n const viewableIndexMin = useSharedValue(0);\n const viewableIndexMax = useSharedValue(0);\n\n // If list is nested there may be an outer scrollview\n const outerScrollOffset = props.outerScrollOffset || DEFAULT_VAL;\n const outerScrollInit = useSharedValue(0);\n\n useAnimatedReaction(\n () => {\n return activeIndexAnim.value;\n },\n (cur, prev) => {\n if (cur !== prev && cur >= 0) {\n scrollInit.value = scrollOffset.value;\n outerScrollInit.value = outerScrollOffset.value;\n }\n },\n [outerScrollOffset]\n );\n\n const placeholderOffset = useSharedValue(0);\n\n const isDraggingCell = useDerivedValue(() => {\n return isTouchActiveNative.value && activeIndexAnim.value >= 0;\n }, []);\n\n const autoScrollDistance = useDerivedValue(() => {\n if (!isDraggingCell.value) return 0;\n const innerScrollDiff = scrollOffset.value - scrollInit.value;\n // If list is nested there may be an outer scroll diff\n const outerScrollDiff = outerScrollOffset.value - outerScrollInit.value;\n const scrollDiff = innerScrollDiff + outerScrollDiff;\n return scrollDiff;\n }, []);\n\n const touchPositionDiff = useDerivedValue(() => {\n const extraTranslate = isTouchActiveNative.value\n ? autoScrollDistance.value\n : 0;\n return touchTranslate.value + extraTranslate;\n }, []);\n\n const touchPositionDiffConstrained = useDerivedValue(() => {\n const containerMinusActiveCell =\n containerSize.value - activeCellSize.value + scrollOffset.value;\n\n const offsetRelativeToScrollTop =\n touchPositionDiff.value + activeCellOffset.value;\n const constrained = Math.min(\n containerMinusActiveCell,\n Math.max(scrollOffset.value, offsetRelativeToScrollTop)\n );\n\n const maxTranslateNegative = -activeCellOffset.value;\n const maxTranslatePositive =\n scrollViewSize.value - (activeCellOffset.value + activeCellSize.value);\n\n // Only constrain the touch position while the finger is on the screen. This allows the active cell\n // to snap above/below the fold once let go, if the drag ends at the top/bottom of the screen.\n const constrainedBase = isTouchActiveNative.value\n ? constrained - activeCellOffset.value\n : touchPositionDiff.value;\n\n // Make sure item is constrained to the boundaries of the scrollview\n return Math.min(\n Math.max(constrainedBase, maxTranslateNegative),\n maxTranslatePositive\n );\n }, []);\n\n const hoverAnim = useDerivedValue(() => {\n if (activeIndexAnim.value < 0) return 0;\n return props.dragItemOverflow\n ? touchPositionDiff.value\n : touchPositionDiffConstrained.value;\n }, []);\n\n const hoverOffset = useDerivedValue(() => {\n return hoverAnim.value + activeCellOffset.value;\n }, [hoverAnim, activeCellOffset]);\n\n useDerivedValue(() => {\n // Reset spacer index when we stop hovering\n const isHovering = activeIndexAnim.value >= 0;\n if (!isHovering && spacerIndexAnim.value >= 0) {\n spacerIndexAnim.value = -1;\n }\n }, []);\n\n // Note: this could use a refactor as it combines touch state + cell animation\n const resetTouchedCell = useCallback(() => {\n activeCellOffset.value = 0;\n hasMoved.value = 0;\n }, []);\n\n const value = useMemo(\n () => ({\n activeCellOffset,\n activeCellSize,\n activeIndexAnim,\n containerSize,\n disabled,\n horizontalAnim,\n hoverAnim,\n hoverOffset,\n isDraggingCell,\n isTouchActiveNative,\n panGestureState,\n placeholderOffset,\n resetTouchedCell,\n scrollOffset,\n scrollViewSize,\n spacerIndexAnim,\n touchPositionDiff,\n touchTranslate,\n autoScrollDistance,\n viewableIndexMin,\n viewableIndexMax,\n }),\n [\n activeCellOffset,\n activeCellSize,\n activeIndexAnim,\n containerSize,\n disabled,\n horizontalAnim,\n hoverAnim,\n hoverOffset,\n isDraggingCell,\n isTouchActiveNative,\n panGestureState,\n placeholderOffset,\n resetTouchedCell,\n scrollOffset,\n scrollViewSize,\n spacerIndexAnim,\n touchPositionDiff,\n touchTranslate,\n autoScrollDistance,\n viewableIndexMin,\n viewableIndexMax,\n ]\n );\n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F,CAoBEV,gBApBF,CAqBEC,gBArBF,CAxBY,CAAd,CAiDA,GAAAgC,gBAAA,EAAU,UAAM,CACdtD,KAAK,CAACuD,aAAN,cAAAvD,KAAK,CAACuD,aAAN,CAAsB5D,KAAtB,EACD,CAFD,CAEG,CAACA,KAAD,CAFH,EAIA,MAAOA,MAAP,CACD"} \ No newline at end of file diff --git a/lib/commonjs/context/cellContext.js b/lib/commonjs/context/cellContext.js index 2caf0721..ea9b03c9 100644 --- a/lib/commonjs/context/cellContext.js +++ b/lib/commonjs/context/cellContext.js @@ -5,7 +5,7 @@ exports.default = void 0; var _react = _interopRequireWildcard(require("react")); var _utils = require("../utils"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/cellContext.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/cellContext.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); diff --git a/lib/commonjs/context/cellContext.js.map b/lib/commonjs/context/cellContext.js.map index ce401a31..db0b77ee 100644 --- a/lib/commonjs/context/cellContext.js.map +++ b/lib/commonjs/context/cellContext.js.map @@ -1 +1 @@ -{"version":3,"names":["CellContext","React","createContext","undefined","CellProvider","isActive","children","value","useMemo","typedMemo","useIsActive","useContext","Error"],"sources":["cellContext.tsx"],"sourcesContent":["import React, { useContext, useMemo } from \"react\";\nimport { typedMemo } from \"../utils\";\n\ntype CellContextValue = {\n isActive: boolean;\n};\n\nconst CellContext = React.createContext(\n undefined\n);\n\ntype Props = {\n isActive: boolean;\n children: React.ReactNode;\n};\n\nexport function CellProvider({ isActive, children }: Props) {\n const value = useMemo(\n () => ({\n isActive,\n }),\n [isActive]\n );\n return {children};\n}\n\nexport default typedMemo(CellProvider);\n\nexport function useIsActive() {\n const value = useContext(CellContext);\n if (!value) {\n throw new Error(\"useIsActive must be called from within CellProvider!\");\n }\n return value.isActive;\n}\n"],"mappings":"kJAAA,qDACA,+B,wlCAMA,GAAMA,YAAW,CAAGC,cAAA,CAAMC,aAAN,CAClBC,SADkB,CAApB,CASO,QAASC,aAAT,MAAqD,IAA7BC,SAA6B,MAA7BA,QAA6B,CAAnBC,QAAmB,MAAnBA,QAAmB,CAC1D,GAAMC,MAAK,CAAG,GAAAC,cAAA,EACZ,iBAAO,CACLH,QAAQ,CAARA,QADK,CAAP,EADY,CAIZ,CAACA,QAAD,CAJY,CAAd,CAMA,MAAO,8BAAC,WAAD,CAAa,QAAb,EAAsB,KAAK,CAAEE,KAA7B,6EAAqCD,QAArC,CAAP,CACD,C,aAEc,GAAAG,gBAAA,EAAUL,YAAV,C,0BAER,QAASM,YAAT,EAAuB,CAC5B,GAAMH,MAAK,CAAG,GAAAI,iBAAA,EAAWX,WAAX,CAAd,CACA,GAAI,CAACO,KAAL,CAAY,CACV,KAAM,IAAIK,MAAJ,CAAU,sDAAV,CAAN,CACD,CACD,MAAOL,MAAK,CAACF,QAAb,CACD"} \ No newline at end of file +{"version":3,"names":["CellContext","React","createContext","undefined","CellProvider","isActive","children","value","useMemo","typedMemo","useIsActive","useContext","Error"],"sources":["cellContext.tsx"],"sourcesContent":["import React, { useContext, useMemo } from \"react\";\nimport { typedMemo } from \"../utils\";\n\ntype CellContextValue = {\n isActive: boolean;\n};\n\nconst CellContext = React.createContext(\n undefined\n);\n\ntype Props = {\n isActive: boolean;\n children: React.ReactNode;\n};\n\nexport function CellProvider({ isActive, children }: Props) {\n const value = useMemo(\n () => ({\n isActive,\n }),\n [isActive]\n );\n return {children};\n}\n\nexport default typedMemo(CellProvider);\n\nexport function useIsActive() {\n const value = useContext(CellContext);\n if (!value) {\n throw new Error(\"useIsActive must be called from within CellProvider!\");\n }\n return value.isActive;\n}\n"],"mappings":"kJAAA,qDACA,+B,smCAMA,GAAMA,YAAW,CAAGC,cAAA,CAAMC,aAAN,CAClBC,SADkB,CAApB,CASO,QAASC,aAAT,MAAqD,IAA7BC,SAA6B,MAA7BA,QAA6B,CAAnBC,QAAmB,MAAnBA,QAAmB,CAC1D,GAAMC,MAAK,CAAG,GAAAC,cAAA,EACZ,iBAAO,CACLH,QAAQ,CAARA,QADK,CAAP,EADY,CAIZ,CAACA,QAAD,CAJY,CAAd,CAMA,MAAO,8BAAC,WAAD,CAAa,QAAb,EAAsB,KAAK,CAAEE,KAA7B,6EAAqCD,QAArC,CAAP,CACD,C,aAEc,GAAAG,gBAAA,EAAUL,YAAV,C,0BAER,QAASM,YAAT,EAAuB,CAC5B,GAAMH,MAAK,CAAG,GAAAI,iBAAA,EAAWX,WAAX,CAAd,CACA,GAAI,CAACO,KAAL,CAAY,CACV,KAAM,IAAIK,MAAJ,CAAU,sDAAV,CAAN,CACD,CACD,MAAOL,MAAK,CAACF,QAAb,CACD"} \ No newline at end of file diff --git a/lib/commonjs/context/draggableFlatListContext.js b/lib/commonjs/context/draggableFlatListContext.js index da8182f7..f0651533 100644 --- a/lib/commonjs/context/draggableFlatListContext.js +++ b/lib/commonjs/context/draggableFlatListContext.js @@ -3,7 +3,7 @@ exports.default = DraggableFlatListProvider; exports.useDraggableFlatListContext = useDraggableFlatListContext; var _react = _interopRequireWildcard(require("react")); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/draggableFlatListContext.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/draggableFlatListContext.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); diff --git a/lib/commonjs/context/draggableFlatListContext.js.map b/lib/commonjs/context/draggableFlatListContext.js.map index de2c6554..bc8f674a 100644 --- a/lib/commonjs/context/draggableFlatListContext.js.map +++ b/lib/commonjs/context/draggableFlatListContext.js.map @@ -1 +1 @@ -{"version":3,"names":["DraggableFlatListContext","React","createContext","undefined","DraggableFlatListProvider","activeKey","keyExtractor","horizontal","layoutAnimationDisabled","children","value","useMemo","useDraggableFlatListContext","useContext","Error"],"sources":["draggableFlatListContext.tsx"],"sourcesContent":["import React, { useContext, useMemo } from \"react\";\n\ntype Props = {\n activeKey: string | null;\n keyExtractor: (item: T, index: number) => string;\n horizontal: boolean;\n layoutAnimationDisabled: boolean;\n children: React.ReactNode;\n};\n\ntype DraggableFlatListContextValue = Omit, \"children\">;\n\nconst DraggableFlatListContext = React.createContext<\n DraggableFlatListContextValue | undefined\n>(undefined);\n\nexport default function DraggableFlatListProvider({\n activeKey,\n keyExtractor,\n horizontal,\n layoutAnimationDisabled,\n children,\n}: Props) {\n const value = useMemo(\n () => ({\n activeKey,\n keyExtractor,\n horizontal,\n layoutAnimationDisabled,\n }),\n [activeKey, keyExtractor, horizontal, layoutAnimationDisabled]\n );\n\n return (\n \n {children}\n \n );\n}\n\nexport function useDraggableFlatListContext() {\n const value = useContext(DraggableFlatListContext);\n if (!value) {\n throw new Error(\n \"useDraggableFlatListContext must be called within DraggableFlatListProvider\"\n );\n }\n return value as DraggableFlatListContextValue;\n}\n"],"mappings":"mKAAA,qD,qmCAYA,GAAMA,yBAAwB,CAAGC,cAAA,CAAMC,aAAN,CAE/BC,SAF+B,CAAjC,CAIe,QAASC,0BAAT,MAMF,IALXC,UAKW,MALXA,SAKW,CAJXC,YAIW,MAJXA,YAIW,CAHXC,UAGW,MAHXA,UAGW,CAFXC,uBAEW,MAFXA,uBAEW,CADXC,QACW,MADXA,QACW,CACX,GAAMC,MAAK,CAAG,GAAAC,cAAA,EACZ,iBAAO,CACLN,SAAS,CAATA,SADK,CAELC,YAAY,CAAZA,YAFK,CAGLC,UAAU,CAAVA,UAHK,CAILC,uBAAuB,CAAvBA,uBAJK,CAAP,EADY,CAOZ,CAACH,SAAD,CAAYC,YAAZ,CAA0BC,UAA1B,CAAsCC,uBAAtC,CAPY,CAAd,CAUA,MACE,8BAAC,wBAAD,CAA0B,QAA1B,EAAmC,KAAK,CAAEE,KAA1C,4EACGD,QADH,CADF,CAKD,CAEM,QAASG,4BAAT,EAA0C,CAC/C,GAAMF,MAAK,CAAG,GAAAG,iBAAA,EAAWb,wBAAX,CAAd,CACA,GAAI,CAACU,KAAL,CAAY,CACV,KAAM,IAAII,MAAJ,CACJ,6EADI,CAAN,CAGD,CACD,MAAOJ,MAAP,CACD"} \ No newline at end of file +{"version":3,"names":["DraggableFlatListContext","React","createContext","undefined","DraggableFlatListProvider","activeKey","keyExtractor","horizontal","layoutAnimationDisabled","children","value","useMemo","useDraggableFlatListContext","useContext","Error"],"sources":["draggableFlatListContext.tsx"],"sourcesContent":["import React, { useContext, useMemo } from \"react\";\n\ntype Props = {\n activeKey: string | null;\n keyExtractor: (item: T, index: number) => string;\n horizontal: boolean;\n layoutAnimationDisabled: boolean;\n children: React.ReactNode;\n};\n\ntype DraggableFlatListContextValue = Omit, \"children\">;\n\nconst DraggableFlatListContext = React.createContext<\n DraggableFlatListContextValue | undefined\n>(undefined);\n\nexport default function DraggableFlatListProvider({\n activeKey,\n keyExtractor,\n horizontal,\n layoutAnimationDisabled,\n children,\n}: Props) {\n const value = useMemo(\n () => ({\n activeKey,\n keyExtractor,\n horizontal,\n layoutAnimationDisabled,\n }),\n [activeKey, keyExtractor, horizontal, layoutAnimationDisabled]\n );\n\n return (\n \n {children}\n \n );\n}\n\nexport function useDraggableFlatListContext() {\n const value = useContext(DraggableFlatListContext);\n if (!value) {\n throw new Error(\n \"useDraggableFlatListContext must be called within DraggableFlatListProvider\"\n );\n }\n return value as DraggableFlatListContextValue;\n}\n"],"mappings":"mKAAA,qD,mnCAYA,GAAMA,yBAAwB,CAAGC,cAAA,CAAMC,aAAN,CAE/BC,SAF+B,CAAjC,CAIe,QAASC,0BAAT,MAMF,IALXC,UAKW,MALXA,SAKW,CAJXC,YAIW,MAJXA,YAIW,CAHXC,UAGW,MAHXA,UAGW,CAFXC,uBAEW,MAFXA,uBAEW,CADXC,QACW,MADXA,QACW,CACX,GAAMC,MAAK,CAAG,GAAAC,cAAA,EACZ,iBAAO,CACLN,SAAS,CAATA,SADK,CAELC,YAAY,CAAZA,YAFK,CAGLC,UAAU,CAAVA,UAHK,CAILC,uBAAuB,CAAvBA,uBAJK,CAAP,EADY,CAOZ,CAACH,SAAD,CAAYC,YAAZ,CAA0BC,UAA1B,CAAsCC,uBAAtC,CAPY,CAAd,CAUA,MACE,8BAAC,wBAAD,CAA0B,QAA1B,EAAmC,KAAK,CAAEE,KAA1C,4EACGD,QADH,CADF,CAKD,CAEM,QAASG,4BAAT,EAA0C,CAC/C,GAAMF,MAAK,CAAG,GAAAG,iBAAA,EAAWb,wBAAX,CAAd,CACA,GAAI,CAACU,KAAL,CAAY,CACV,KAAM,IAAII,MAAJ,CACJ,6EADI,CAAN,CAGD,CACD,MAAOJ,MAAP,CACD"} \ No newline at end of file diff --git a/lib/commonjs/context/nestableScrollContainerContext.js b/lib/commonjs/context/nestableScrollContainerContext.js index 4aed9ea4..5d2545a0 100644 --- a/lib/commonjs/context/nestableScrollContainerContext.js +++ b/lib/commonjs/context/nestableScrollContainerContext.js @@ -9,7 +9,7 @@ var _slicedToArray2 = _interopRequireDefault( var _react = _interopRequireWildcard(require("react")); var _reactNativeReanimated = require("react-native-reanimated"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/nestableScrollContainerContext.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/nestableScrollContainerContext.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); diff --git a/lib/commonjs/context/nestableScrollContainerContext.js.map b/lib/commonjs/context/nestableScrollContainerContext.js.map index fcc2f0f8..b93e825b 100644 --- a/lib/commonjs/context/nestableScrollContainerContext.js.map +++ b/lib/commonjs/context/nestableScrollContainerContext.js.map @@ -1 +1 @@ -{"version":3,"names":["NestableScrollContainerContext","React","createContext","undefined","useSetupNestableScrollContextValue","forwardedRef","useState","outerScrollEnabled","setOuterScrollEnabled","scrollViewSize","useSharedValue","scrollableRefInner","useRef","scrollableRef","outerScrollOffset","containerSize","contextVal","useMemo","NestableScrollContainerProvider","children","useNestableScrollContainerContext","value","useContext","useSafeNestableScrollContainerContext","Error"],"sources":["nestableScrollContainerContext.tsx"],"sourcesContent":["import React, { useContext, useMemo, useRef, useState } from \"react\";\nimport { ScrollView } from \"react-native-gesture-handler\";\nimport Animated, { useSharedValue } from \"react-native-reanimated\";\n\ntype NestableScrollContainerContextVal = ReturnType<\n typeof useSetupNestableScrollContextValue\n>;\nconst NestableScrollContainerContext = React.createContext<\n NestableScrollContainerContextVal | undefined\n>(undefined);\n\nfunction useSetupNestableScrollContextValue({\n forwardedRef,\n}: {\n forwardedRef?: React.MutableRefObject;\n}) {\n const [outerScrollEnabled, setOuterScrollEnabled] = useState(true);\n const scrollViewSize = useSharedValue(0);\n const scrollableRefInner = useRef(null);\n const scrollableRef = forwardedRef || scrollableRefInner;\n const outerScrollOffset = useSharedValue(0);\n const containerSize = useSharedValue(0);\n\n const contextVal = useMemo(\n () => ({\n outerScrollEnabled,\n setOuterScrollEnabled,\n outerScrollOffset,\n scrollViewSize,\n scrollableRef,\n containerSize,\n }),\n [outerScrollEnabled]\n );\n\n return contextVal;\n}\n\nexport function NestableScrollContainerProvider({\n children,\n forwardedRef,\n}: {\n children: React.ReactNode;\n forwardedRef?: React.MutableRefObject;\n}) {\n const contextVal = useSetupNestableScrollContextValue({ forwardedRef });\n return (\n \n {children}\n \n );\n}\n\nexport function useNestableScrollContainerContext() {\n const value = useContext(NestableScrollContainerContext);\n return value;\n}\n\nexport function useSafeNestableScrollContainerContext() {\n const value = useNestableScrollContainerContext();\n if (!value) {\n throw new Error(\n \"useSafeNestableScrollContainerContext must be called within a NestableScrollContainerContext.Provider\"\n );\n }\n return value;\n}\n"],"mappings":"gdAAA,qDAEA,8D,2mCAKA,GAAMA,+BAA8B,CAAGC,cAAA,CAAMC,aAAN,CAErCC,SAFqC,CAAvC,CAIA,QAASC,mCAAT,MAIG,IAHDC,aAGC,MAHDA,YAGC,eACmD,GAAAC,eAAA,EAAS,IAAT,CADnD,qDACMC,kBADN,eAC0BC,qBAD1B,eAED,GAAMC,eAAc,CAAG,GAAAC,qCAAA,EAAe,CAAf,CAAvB,CACA,GAAMC,mBAAkB,CAAG,GAAAC,aAAA,EAAmB,IAAnB,CAA3B,CACA,GAAMC,cAAa,CAAGR,YAAY,EAAIM,kBAAtC,CACA,GAAMG,kBAAiB,CAAG,GAAAJ,qCAAA,EAAe,CAAf,CAA1B,CACA,GAAMK,cAAa,CAAG,GAAAL,qCAAA,EAAe,CAAf,CAAtB,CAEA,GAAMM,WAAU,CAAG,GAAAC,cAAA,EACjB,iBAAO,CACLV,kBAAkB,CAAlBA,kBADK,CAELC,qBAAqB,CAArBA,qBAFK,CAGLM,iBAAiB,CAAjBA,iBAHK,CAILL,cAAc,CAAdA,cAJK,CAKLI,aAAa,CAAbA,aALK,CAMLE,aAAa,CAAbA,aANK,CAAP,EADiB,CASjB,CAACR,kBAAD,CATiB,CAAnB,CAYA,MAAOS,WAAP,CACD,CAEM,QAASE,gCAAT,OAMJ,IALDC,SAKC,OALDA,QAKC,CAJDd,YAIC,OAJDA,YAIC,CACD,GAAMW,WAAU,CAAGZ,kCAAkC,CAAC,CAAEC,YAAY,CAAZA,YAAF,CAAD,CAArD,CACA,MACE,8BAAC,8BAAD,CAAgC,QAAhC,EAAyC,KAAK,CAAEW,UAAhD,4EACGG,QADH,CADF,CAKD,CAEM,QAASC,kCAAT,EAA6C,CAClD,GAAMC,MAAK,CAAG,GAAAC,iBAAA,EAAWtB,8BAAX,CAAd,CACA,MAAOqB,MAAP,CACD,CAEM,QAASE,sCAAT,EAAiD,CACtD,GAAMF,MAAK,CAAGD,iCAAiC,EAA/C,CACA,GAAI,CAACC,KAAL,CAAY,CACV,KAAM,IAAIG,MAAJ,CACJ,uGADI,CAAN,CAGD,CACD,MAAOH,MAAP,CACD"} \ No newline at end of file +{"version":3,"names":["NestableScrollContainerContext","React","createContext","undefined","useSetupNestableScrollContextValue","forwardedRef","useState","outerScrollEnabled","setOuterScrollEnabled","scrollViewSize","useSharedValue","scrollableRefInner","useRef","scrollableRef","outerScrollOffset","containerSize","contextVal","useMemo","NestableScrollContainerProvider","children","useNestableScrollContainerContext","value","useContext","useSafeNestableScrollContainerContext","Error"],"sources":["nestableScrollContainerContext.tsx"],"sourcesContent":["import React, { useContext, useMemo, useRef, useState } from \"react\";\nimport { ScrollView } from \"react-native-gesture-handler\";\nimport Animated, { useSharedValue } from \"react-native-reanimated\";\n\ntype NestableScrollContainerContextVal = ReturnType<\n typeof useSetupNestableScrollContextValue\n>;\nconst NestableScrollContainerContext = React.createContext<\n NestableScrollContainerContextVal | undefined\n>(undefined);\n\nfunction useSetupNestableScrollContextValue({\n forwardedRef,\n}: {\n forwardedRef?: React.MutableRefObject;\n}) {\n const [outerScrollEnabled, setOuterScrollEnabled] = useState(true);\n const scrollViewSize = useSharedValue(0);\n const scrollableRefInner = useRef(null);\n const scrollableRef = forwardedRef || scrollableRefInner;\n const outerScrollOffset = useSharedValue(0);\n const containerSize = useSharedValue(0);\n\n const contextVal = useMemo(\n () => ({\n outerScrollEnabled,\n setOuterScrollEnabled,\n outerScrollOffset,\n scrollViewSize,\n scrollableRef,\n containerSize,\n }),\n [outerScrollEnabled]\n );\n\n return contextVal;\n}\n\nexport function NestableScrollContainerProvider({\n children,\n forwardedRef,\n}: {\n children: React.ReactNode;\n forwardedRef?: React.MutableRefObject;\n}) {\n const contextVal = useSetupNestableScrollContextValue({ forwardedRef });\n return (\n \n {children}\n \n );\n}\n\nexport function useNestableScrollContainerContext() {\n const value = useContext(NestableScrollContainerContext);\n return value;\n}\n\nexport function useSafeNestableScrollContainerContext() {\n const value = useNestableScrollContainerContext();\n if (!value) {\n throw new Error(\n \"useSafeNestableScrollContainerContext must be called within a NestableScrollContainerContext.Provider\"\n );\n }\n return value;\n}\n"],"mappings":"gdAAA,qDAEA,8D,ynCAKA,GAAMA,+BAA8B,CAAGC,cAAA,CAAMC,aAAN,CAErCC,SAFqC,CAAvC,CAIA,QAASC,mCAAT,MAIG,IAHDC,aAGC,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sContext.js index 14681e4e..5507761f 100644 --- a/lib/commonjs/context/propsContext.js +++ b/lib/commonjs/context/propsContext.js @@ -7,7 +7,7 @@ var _objectWithoutProperties2 = _interopRequireDefault( ); var _react = _interopRequireWildcard(require("react")); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/propsContext.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/propsContext.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); diff --git a/lib/commonjs/context/propsContext.js.map b/lib/commonjs/context/propsContext.js.map index b4105ad9..f0cc36ae 100644 --- a/lib/commonjs/context/propsContext.js.map +++ b/lib/commonjs/context/propsContext.js.map @@ -1 +1 @@ -{"version":3,"names":["PropsContext","React","createContext","undefined","PropsProvider","children","props","useProps","value","useContext","Error"],"sources":["propsContext.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { DraggableFlatListProps } from \"../types\";\n\nconst PropsContext = React.createContext<\n DraggableFlatListProps | undefined\n>(undefined);\n\ntype Props = DraggableFlatListProps & { children: React.ReactNode };\n\nexport default function PropsProvider({ children, ...props }: Props) {\n return (\n {children}\n );\n}\n\nexport function useProps() {\n const value = useContext(PropsContext) as\n | DraggableFlatListProps\n | undefined;\n if (!value) {\n throw new Error(\"useProps must be called from within PropsProvider!\");\n }\n return value;\n}\n"],"mappings":"oTAAA,qD,ylCAGA,GAAMA,aAAY,CAAGC,cAAA,CAAMC,aAAN,CAEnBC,SAFmB,CAArB,CAMe,QAASC,cAAT,MAA4D,IAAhCC,SAAgC,MAAhCA,QAAgC,CAAnBC,KAAmB,0DACzE,MACE,8BAAC,YAAD,CAAc,QAAd,EAAuB,KAAK,CAAEA,KAA9B,4EAAsCD,QAAtC,CADF,CAGD,CAEM,QAASE,SAAT,EAAuB,CAC5B,GAAMC,MAAK,CAAG,GAAAC,iBAAA,EAAWT,YAAX,CAAd,CAGA,GAAI,CAACQ,KAAL,CAAY,CACV,KAAM,IAAIE,MAAJ,CAAU,oDAAV,CAAN,CACD,CACD,MAAOF,MAAP,CACD"} \ No newline at end of file +{"version":3,"names":["PropsContext","React","createContext","undefined","PropsProvider","children","props","useProps","value","useContext","Error"],"sources":["propsContext.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { DraggableFlatListProps } from \"../types\";\n\nconst PropsContext = React.createContext<\n DraggableFlatListProps | undefined\n>(undefined);\n\ntype Props = DraggableFlatListProps & { children: React.ReactNode };\n\nexport default function PropsProvider({ children, ...props }: Props) {\n return (\n {children}\n );\n}\n\nexport function useProps() {\n const value = useContext(PropsContext) as\n | DraggableFlatListProps\n | undefined;\n if (!value) {\n throw new Error(\"useProps must be called from within PropsProvider!\");\n }\n return value;\n}\n"],"mappings":"oTAAA,qD,umCAGA,GAAMA,aAAY,CAAGC,cAAA,CAAMC,aAAN,CAEnBC,SAFmB,CAArB,CAMe,QAASC,cAAT,MAA4D,IAAhCC,SAAgC,MAAhCA,QAAgC,CAAnBC,KAAmB,0DACzE,MACE,8BAAC,YAAD,CAAc,QAAd,EAAuB,KAAK,CAAEA,KAA9B,4EAAsCD,QAAtC,CADF,CAGD,CAEM,QAASE,SAAT,EAAuB,CAC5B,GAAMC,MAAK,CAAG,GAAAC,iBAAA,EAAWT,YAAX,CAAd,CAGA,GAAI,CAACQ,KAAL,CAAY,CACV,KAAM,IAAIE,MAAJ,CAAU,oDAAV,CAAN,CACD,CACD,MAAOF,MAAP,CACD"} \ No newline at end of file diff --git a/lib/commonjs/context/refContext.js b/lib/commonjs/context/refContext.js index 88c1c058..1073b585 100644 --- a/lib/commonjs/context/refContext.js +++ b/lib/commonjs/context/refContext.js @@ -5,7 +5,7 @@ var _react = _interopRequireWildcard(require("react")); var _constants = require("../constants"); var _propsContext = require("./propsContext"); var _jsxFileName = - "/Users/cs/Code/react-native-draggable-flatlist/src/context/refContext.tsx"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/context/refContext.tsx"; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); diff --git a/lib/commonjs/context/refContext.js.map b/lib/commonjs/context/refContext.js.map index 53dea016..77abd90e 100644 --- a/lib/commonjs/context/refContext.js.map +++ b/lib/commonjs/context/refContext.js.map @@ -1 +1 @@ -{"version":3,"names":["RefContext","React","createContext","undefined","RefProvider","children","flatListRef","value","useSetupRefs","useRefs","useContext","Error","flatListRefProp","props","useProps","animationConfig","DEFAULT_PROPS","propsRef","useRef","current","animConfig","animationConfigRef","cellDataRef","Map","keyToIndexRef","containerRef","flatlistRefInternal","flatlistRef","scrollViewRef","refs","useMemo"],"sources":["refContext.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { useMemo, useRef } from \"react\";\nimport { FlatList } from \"react-native-gesture-handler\";\nimport Animated, { WithSpringConfig } from \"react-native-reanimated\";\nimport { DEFAULT_PROPS } from \"../constants\";\nimport { useProps } from \"./propsContext\";\nimport { CellData, DraggableFlatListProps } from \"../types\";\n\ntype RefContextValue = {\n propsRef: React.MutableRefObject>;\n animationConfigRef: React.MutableRefObject;\n cellDataRef: React.MutableRefObject>;\n keyToIndexRef: React.MutableRefObject>;\n containerRef: React.RefObject;\n flatlistRef: React.RefObject> | React.ForwardedRef>;\n scrollViewRef: React.RefObject;\n};\nconst RefContext = React.createContext | undefined>(\n undefined\n);\n\nexport default function RefProvider({\n children,\n flatListRef,\n}: {\n children: React.ReactNode;\n flatListRef?: React.ForwardedRef> | null;\n}) {\n const value = useSetupRefs({ flatListRef });\n return {children};\n}\n\nexport function useRefs() {\n const value = useContext(RefContext);\n if (!value) {\n throw new Error(\n \"useRefs must be called from within a RefContext.Provider!\"\n );\n }\n return value as RefContextValue;\n}\n\nfunction useSetupRefs({\n flatListRef: flatListRefProp,\n}: {\n flatListRef?: React.ForwardedRef> | null;\n}) {\n const props = useProps();\n const { animationConfig = DEFAULT_PROPS.animationConfig } = props;\n\n const propsRef = useRef(props);\n propsRef.current = props;\n const animConfig = {\n ...DEFAULT_PROPS.animationConfig,\n ...animationConfig,\n } as WithSpringConfig;\n const animationConfigRef = useRef(animConfig);\n animationConfigRef.current = animConfig;\n\n const cellDataRef = useRef(new Map());\n const keyToIndexRef = useRef(new Map());\n const containerRef = useRef(null);\n const flatlistRefInternal = useRef>(null);\n const flatlistRef = flatListRefProp || flatlistRefInternal;\n const scrollViewRef = useRef(null);\n\n // useEffect(() => {\n // // This is a workaround for the fact that RN does not respect refs passed in\n // // to renderScrollViewComponent underlying ScrollView (currently not used but\n // // may need to add if we want to use reanimated scrollTo in the future)\n // //@ts-ignore\n // const scrollRef = flatlistRef.current?.getNativeScrollRef();\n // if (!scrollViewRef.current) {\n // //@ts-ignore\n // scrollViewRef(scrollRef);\n // }\n // }, []);\n\n const refs = useMemo(\n () => ({\n animationConfigRef,\n cellDataRef,\n containerRef,\n flatlistRef,\n keyToIndexRef,\n propsRef,\n scrollViewRef,\n }),\n []\n );\n\n return refs;\n}\n"],"mappings":"6GAAA,qDAIA,uCACA,4C,ulCAYA,GAAMA,WAAU,CAAGC,cAAA,CAAMC,aAAN,CACjBC,SADiB,CAAnB,CAIe,QAASC,YAAT,MAMZ,IALDC,SAKC,MALDA,QAKC,CAJDC,WAIC,MAJDA,WAIC,CACD,GAAMC,MAAK,CAAGC,YAAY,CAAI,CAAEF,WAAW,CAAXA,WAAF,CAAJ,CAA1B,CACA,MAAO,8BAAC,UAAD,CAAY,QAAZ,EAAqB,KAAK,CAAEC,KAA5B,6EAAoCF,QAApC,CAAP,CACD,CAEM,QAASI,QAAT,EAAsB,CAC3B,GAAMF,MAAK,CAAG,GAAAG,iBAAA,EAAWV,UAAX,CAAd,CACA,GAAI,CAACO,KAAL,CAAY,CACV,KAAM,IAAII,MAAJ,CACJ,2DADI,CAAN,CAGD,CACD,MAAOJ,MAAP,CACD,CAED,QAASC,aAAT,OAIG,IAHYI,gBAGZ,OAHDN,WAGC,CACD,GAAMO,MAAK,CAAG,GAAAC,sBAAA,GAAd,CADC,0BAE2DD,KAF3D,CAEOE,eAFP,CAEOA,eAFP,gCAEyBC,wBAAA,CAAcD,eAFvC,uBAID,GAAME,SAAQ,CAAG,GAAAC,aAAA,EAAOL,KAAP,CAAjB,CACAI,QAAQ,CAACE,OAAT,CAAmBN,KAAnB,CACA,GAAMO,WAAU,kBACXJ,wBAAA,CAAcD,eADH,CAEXA,eAFW,CAAhB,CAIA,GAAMM,mBAAkB,CAAG,GAAAH,aAAA,EAAOE,UAAP,CAA3B,CACAC,kBAAkB,CAACF,OAAnB,CAA6BC,UAA7B,CAEA,GAAME,YAAW,CAAG,GAAAJ,aAAA,EAAO,GAAIK,IAAJ,EAAP,CAApB,CACA,GAAMC,cAAa,CAAG,GAAAN,aAAA,EAAO,GAAIK,IAAJ,EAAP,CAAtB,CACA,GAAME,aAAY,CAAG,GAAAP,aAAA,EAAsB,IAAtB,CAArB,CACA,GAAMQ,oBAAmB,CAAG,GAAAR,aAAA,EAAoB,IAApB,CAA5B,CACA,GAAMS,YAAW,CAAGf,eAAe,EAAIc,mBAAvC,CACA,GAAME,cAAa,CAAG,GAAAV,aAAA,EAA4B,IAA5B,CAAtB,CAcA,GAAMW,KAAI,CAAG,GAAAC,cAAA,EACX,iBAAO,CACLT,kBAAkB,CAAlBA,kBADK,CAELC,WAAW,CAAXA,WAFK,CAGLG,YAAY,CAAZA,YAHK,CAILE,WAAW,CAAXA,WAJK,CAKLH,aAAa,CAAbA,aALK,CAMLP,QAAQ,CAARA,QANK,CAOLW,aAAa,CAAbA,aAPK,CAAP,EADW,CAUX,EAVW,CAAb,CAaA,MAAOC,KAAP,CACD"} \ No newline at end of file +{"version":3,"names":["RefContext","React","createContext","undefined","RefProvider","children","flatListRef","value","useSetupRefs","useRefs","useContext","Error","flatListRefProp","props","useProps","animationConfig","DEFAULT_PROPS","propsRef","useRef","current","animConfig","animationConfigRef","cellDataRef","Map","keyToIndexRef","containerRef","flatlistRefInternal","flatlistRef","scrollViewRef","refs","useMemo"],"sources":["refContext.tsx"],"sourcesContent":["import React, { useContext } from \"react\";\nimport { useMemo, useRef } from \"react\";\nimport { FlatList } from \"react-native-gesture-handler\";\nimport Animated, { WithSpringConfig } from \"react-native-reanimated\";\nimport { DEFAULT_PROPS } from \"../constants\";\nimport { useProps } from \"./propsContext\";\nimport { CellData, DraggableFlatListProps } from \"../types\";\n\ntype RefContextValue = {\n propsRef: React.MutableRefObject>;\n animationConfigRef: React.MutableRefObject;\n cellDataRef: React.MutableRefObject>;\n keyToIndexRef: React.MutableRefObject>;\n containerRef: React.RefObject;\n flatlistRef: React.RefObject> | React.ForwardedRef>;\n scrollViewRef: React.RefObject;\n};\nconst RefContext = React.createContext | undefined>(\n undefined\n);\n\nexport default function RefProvider({\n children,\n flatListRef,\n}: {\n children: React.ReactNode;\n flatListRef?: React.ForwardedRef> | null;\n}) {\n const value = useSetupRefs({ flatListRef });\n return {children};\n}\n\nexport function useRefs() {\n const value = useContext(RefContext);\n if (!value) {\n throw new Error(\n \"useRefs must be called from within a RefContext.Provider!\"\n );\n }\n return value as RefContextValue;\n}\n\nfunction useSetupRefs({\n flatListRef: flatListRefProp,\n}: {\n flatListRef?: React.ForwardedRef> | null;\n}) {\n const props = useProps();\n const { animationConfig = DEFAULT_PROPS.animationConfig } = props;\n\n const propsRef = useRef(props);\n propsRef.current = props;\n const animConfig = {\n ...DEFAULT_PROPS.animationConfig,\n ...animationConfig,\n } as WithSpringConfig;\n const animationConfigRef = useRef(animConfig);\n animationConfigRef.current = animConfig;\n\n const cellDataRef = useRef(new Map());\n const keyToIndexRef = useRef(new Map());\n const containerRef = useRef(null);\n const flatlistRefInternal = useRef>(null);\n const flatlistRef = flatListRefProp || flatlistRefInternal;\n const scrollViewRef = useRef(null);\n\n // useEffect(() => {\n // // This is a workaround for the fact that RN does not respect refs passed in\n // // to renderScrollViewComponent underlying ScrollView (currently not used but\n // // may need to add if we want to use reanimated scrollTo in the future)\n // //@ts-ignore\n // const scrollRef = flatlistRef.current?.getNativeScrollRef();\n // if (!scrollViewRef.current) {\n // //@ts-ignore\n // scrollViewRef(scrollRef);\n // }\n // }, []);\n\n const refs = useMemo(\n () => ({\n animationConfigRef,\n cellDataRef,\n containerRef,\n flatlistRef,\n keyToIndexRef,\n propsRef,\n scrollViewRef,\n }),\n []\n );\n\n return refs;\n}\n"],"mappings":"6GAAA,qDAIA,uCACA,4C,qmCAYA,GAAMA,WAAU,CAAGC,cAAA,CAAMC,aAAN,CACjBC,SADiB,CAAnB,CAIe,QAASC,YAAT,MAMZ,IALDC,SAKC,MALDA,QAKC,CAJDC,WAIC,MAJDA,WAIC,CACD,GAAMC,MAAK,CAAGC,YAAY,CAAI,CAAEF,WAAW,CAAXA,WAAF,CAAJ,CAA1B,CACA,MAAO,8BAAC,UAAD,CAAY,QAAZ,EAAqB,KAAK,CAAEC,KAA5B,6EAAoCF,QAApC,CAAP,CACD,CAEM,QAASI,QAAT,EAAsB,CAC3B,GAAMF,MAAK,CAAG,GAAAG,iBAAA,EAAWV,UAAX,CAAd,CACA,GAAI,CAACO,KAAL,CAAY,CACV,KAAM,IAAII,MAAJ,CACJ,2DADI,CAAN,CAGD,CACD,MAAOJ,MAAP,CACD,CAED,QAASC,aAAT,OAIG,IAHYI,gBAGZ,OAHDN,WAGC,CACD,GAAMO,MAAK,CAAG,GAAAC,sBAAA,GAAd,CADC,0BAE2DD,KAF3D,CAEOE,eAFP,CAEOA,eAFP,gCAEyBC,wBAAA,CAAcD,eAFvC,uBAID,GAAME,SAAQ,CAAG,GAAAC,aAAA,EAAOL,KAAP,CAAjB,CACAI,QAAQ,CAACE,OAAT,CAAmBN,KAAnB,CACA,GAAMO,WAAU,kBACXJ,wBAAA,CAAcD,eADH,CAEXA,eAFW,CAAhB,CAIA,GAAMM,mBAAkB,CAAG,GAAAH,aAAA,EAAOE,UAAP,CAA3B,CACAC,kBAAkB,CAACF,OAAnB,CAA6BC,UAA7B,CAEA,GAAME,YAAW,CAAG,GAAAJ,aAAA,EAAO,GAAIK,IAAJ,EAAP,CAApB,CACA,GAAMC,cAAa,CAAG,GAAAN,aAAA,EAAO,GAAIK,IAAJ,EAAP,CAAtB,CACA,GAAME,aAAY,CAAG,GAAAP,aAAA,EAAsB,IAAtB,CAArB,CACA,GAAMQ,oBAAmB,CAAG,GAAAR,aAAA,EAAoB,IAApB,CAA5B,CACA,GAAMS,YAAW,CAAGf,eAAe,EAAIc,mBAAvC,CACA,GAAME,cAAa,CAAG,GAAAV,aAAA,EAA4B,IAA5B,CAAtB,CAcA,GAAMW,KAAI,CAAG,GAAAC,cAAA,EACX,iBAAO,CACLT,kBAAkB,CAAlBA,kBADK,CAELC,WAAW,CAAXA,WAFK,CAGLG,YAAY,CAAZA,YAHK,CAILE,WAAW,CAAXA,WAJK,CAKLH,aAAa,CAAbA,aALK,CAMLP,QAAQ,CAARA,QANK,CAOLW,aAAa,CAAbA,aAPK,CAAP,EADW,CAUX,EAVW,CAAb,CAaA,MAAOC,KAAP,CACD"} \ No newline at end of file diff --git a/lib/commonjs/hooks/useAutoScroll.js b/lib/commonjs/hooks/useAutoScroll.js index b74d4b54..46b34978 100644 --- a/lib/commonjs/hooks/useAutoScroll.js +++ b/lib/commonjs/hooks/useAutoScroll.js @@ -36,7 +36,7 @@ function useAutoScroll() { "function _f(){const{hoverOffset,scrollOffset}=jsThis._closure;{return hoverOffset.value-scrollOffset.value;}}"; _f.__workletHash = 10763890843319; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (29:44)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (29:44)"; return _f; })(), [] @@ -54,7 +54,7 @@ function useAutoScroll() { "function _f(){const{scrollOffset,SCROLL_POSITION_TOLERANCE}=jsThis._closure;{return scrollOffset.value-SCROLL_POSITION_TOLERANCE<=0;}}"; _f.__workletHash = 15578879662595; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (33:39)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (33:39)"; return _f; })(), [] @@ -79,7 +79,7 @@ function useAutoScroll() { "function _f(){const{scrollOffset,containerSize,SCROLL_POSITION_TOLERANCE,scrollViewSize}=jsThis._closure;{return scrollOffset.value+containerSize.value+SCROLL_POSITION_TOLERANCE>=scrollViewSize.value;}}"; _f.__workletHash = 7372520673244; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (37:41)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (37:41)"; return _f; })(), [] @@ -94,7 +94,7 @@ function useAutoScroll() { "function _f(){const{hoverScreenOffset}=jsThis._closure;{return Math.max(0,hoverScreenOffset.value);}}"; _f.__workletHash = 5945680760068; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (44:40)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (44:40)"; return _f; })(), [] @@ -115,7 +115,7 @@ function useAutoScroll() { "function _f(){const{hoverScreenOffset,activeCellSize,containerSize}=jsThis._closure;{const hoverPlusActiveCell=hoverScreenOffset.value+activeCellSize.value;return Math.max(0,containerSize.value-hoverPlusActiveCell);}}"; _f.__workletHash = 17447360140833; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (48:43)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (48:43)"; return _f; })(), [] @@ -133,7 +133,7 @@ function useAutoScroll() { "function _f(){const{distToTopEdge,autoscrollThreshold}=jsThis._closure;{return distToTopEdge.value<=autoscrollThreshold;}}"; _f.__workletHash = 499688299934; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (53:38)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (53:38)"; return _f; })() ); @@ -150,7 +150,7 @@ function useAutoScroll() { "function _f(){const{distToBottomEdge,autoscrollThreshold}=jsThis._closure;{return distToBottomEdge.value<=autoscrollThreshold;}}"; _f.__workletHash = 10361122491518; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (57:41)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (57:41)"; return _f; })(), [] @@ -166,7 +166,7 @@ function useAutoScroll() { "function _f(){const{activeIndexAnim}=jsThis._closure;{return activeIndexAnim.value>=0;}}"; _f.__workletHash = 16254827243008; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (62:39)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (62:39)"; return _f; })(), [] @@ -181,7 +181,7 @@ function useAutoScroll() { "function _f(){const{dragIsActive}=jsThis._closure;{return dragIsActive.value;}}"; _f.__workletHash = 4207325526803; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (67:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (67:4)"; return _f; })(), (function () { @@ -195,7 +195,7 @@ function useAutoScroll() { "function _f(cur,prev){const{scrollTarget,scrollOffset}=jsThis._closure;{if(cur&&!prev){scrollTarget.value=scrollOffset.value;}}}"; _f.__workletHash = 14491611054056; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (70:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (70:4)"; return _f; })() ); @@ -230,7 +230,7 @@ function useAutoScroll() { "function _f(){const{scrollTarget,scrollOffset,SCROLL_POSITION_TOLERANCE,isAtTopEdge,isAtBottomEdge,isScrolledUp,isScrolledDown,activeIndexAnim}=jsThis._closure;{const scrollTargetDiff=Math.abs(scrollTarget.value-scrollOffset.value);const hasScrolledToTarget=scrollTargetDiff=0;return hasScrolledToTarget&&isAtEdge&&!isEdgeDisabled&&cellIsActive;}}"; _f.__workletHash = 8742571894036; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (77:43)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (77:43)"; return _f; })(), [] @@ -282,7 +282,7 @@ function useAutoScroll() { "function _f(){const{shouldAutoScroll,isAtTopEdge,distToTopEdge,distToBottomEdge,autoscrollThreshold,autoscrollSpeed,scrollOffset,scrollViewSize,containerSize,scrollTarget,runOnJS,scrollToInternal}=jsThis._closure;{if(!shouldAutoScroll.value)return;const distFromEdge=isAtTopEdge.value?distToTopEdge.value:distToBottomEdge.value;const speedPct=1-distFromEdge/autoscrollThreshold;const offset=speedPct*autoscrollSpeed;const targetOffset=isAtTopEdge.value?Math.max(0,scrollOffset.value-offset):Math.min(scrollOffset.value+offset,scrollViewSize.value-containerSize.value);scrollTarget.value=targetOffset;runOnJS(scrollToInternal)(targetOffset);}}"; _f.__workletHash = 8964641543522; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (97:18)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useAutoScroll.tsx (97:18)"; return _f; })(), [] diff --git a/lib/commonjs/hooks/useAutoScroll.js.map b/lib/commonjs/hooks/useAutoScroll.js.map index e0b04e6e..190257f5 100644 --- a/lib/commonjs/hooks/useAutoScroll.js.map +++ b/lib/commonjs/hooks/useAutoScroll.js.map @@ -1 +1 @@ -{"version":3,"names":["useAutoScroll","useRefs","flatlistRef","useProps","autoscrollThreshold","DEFAULT_PROPS","autoscrollSpeed","useAnimatedValues","scrollOffset","scrollViewSize","containerSize","activeCellSize","hoverOffset","activeIndexAnim","hoverScreenOffset","useDerivedValue","value","isScrolledUp","SCROLL_POSITION_TOLERANCE","isScrolledDown","distToTopEdge","Math","max","distToBottomEdge","hoverPlusActiveCell","isAtTopEdge","isAtBottomEdge","scrollTarget","useSharedValue","dragIsActive","useAnimatedReaction","cur","prev","shouldAutoScroll","scrollTargetDiff","abs","hasScrolledToTarget","isAtEdge","topDisabled","bottomDisabled","isEdgeDisabled","cellIsActive","scrollToInternal","offset","current","scrollToOffset","animated","distFromEdge","speedPct","targetOffset","min","runOnJS"],"sources":["useAutoScroll.tsx"],"sourcesContent":["import {\n runOnJS,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { DEFAULT_PROPS, SCROLL_POSITION_TOLERANCE } from \"../constants\";\nimport { useProps } from \"../context/propsContext\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport { useRefs } from \"../context/refContext\";\n\nexport function useAutoScroll() {\n const { flatlistRef } = useRefs();\n\n const {\n autoscrollThreshold = DEFAULT_PROPS.autoscrollThreshold,\n autoscrollSpeed = DEFAULT_PROPS.autoscrollSpeed,\n } = useProps();\n\n const {\n scrollOffset,\n scrollViewSize,\n containerSize,\n activeCellSize,\n hoverOffset,\n activeIndexAnim,\n } = useAnimatedValues();\n\n const hoverScreenOffset = useDerivedValue(() => {\n return hoverOffset.value - scrollOffset.value;\n }, []);\n\n const isScrolledUp = useDerivedValue(() => {\n return scrollOffset.value - SCROLL_POSITION_TOLERANCE <= 0;\n }, []);\n\n const isScrolledDown = useDerivedValue(() => {\n return (\n scrollOffset.value + containerSize.value + SCROLL_POSITION_TOLERANCE >=\n scrollViewSize.value\n );\n }, []);\n\n const distToTopEdge = useDerivedValue(() => {\n return Math.max(0, hoverScreenOffset.value);\n }, []);\n\n const distToBottomEdge = useDerivedValue(() => {\n const hoverPlusActiveCell = hoverScreenOffset.value + activeCellSize.value;\n return Math.max(0, containerSize.value - hoverPlusActiveCell);\n }, []);\n\n const isAtTopEdge = useDerivedValue(() => {\n return distToTopEdge.value <= autoscrollThreshold;\n });\n\n const isAtBottomEdge = useDerivedValue(() => {\n return distToBottomEdge.value <= autoscrollThreshold;\n }, []);\n\n const scrollTarget = useSharedValue(0);\n const dragIsActive = useDerivedValue(() => {\n return activeIndexAnim.value >= 0;\n }, []);\n\n useAnimatedReaction(\n () => {\n return dragIsActive.value;\n },\n (cur, prev) => {\n if (cur && !prev) {\n scrollTarget.value = scrollOffset.value;\n }\n }\n );\n\n const shouldAutoScroll = useDerivedValue(() => {\n const scrollTargetDiff = Math.abs(scrollTarget.value - scrollOffset.value);\n const hasScrolledToTarget = scrollTargetDiff < SCROLL_POSITION_TOLERANCE;\n\n const isAtEdge = isAtTopEdge.value || isAtBottomEdge.value;\n const topDisabled = isAtTopEdge.value && isScrolledUp.value;\n const bottomDisabled = isAtBottomEdge.value && isScrolledDown.value;\n const isEdgeDisabled = topDisabled || bottomDisabled;\n\n const cellIsActive = activeIndexAnim.value >= 0;\n\n return hasScrolledToTarget && isAtEdge && !isEdgeDisabled && cellIsActive;\n }, []);\n\n function scrollToInternal(offset: number) {\n if (flatlistRef && \"current\" in flatlistRef) {\n flatlistRef.current?.scrollToOffset({ offset, animated: true });\n }\n }\n\n useDerivedValue(() => {\n if (!shouldAutoScroll.value) return;\n\n const distFromEdge = isAtTopEdge.value\n ? distToTopEdge.value\n : distToBottomEdge.value;\n const speedPct = 1 - distFromEdge / autoscrollThreshold!;\n const offset = speedPct * autoscrollSpeed;\n const targetOffset = isAtTopEdge.value\n ? Math.max(0, scrollOffset.value - offset)\n : Math.min(\n scrollOffset.value + offset,\n scrollViewSize.value - containerSize.value\n );\n\n scrollTarget.value = targetOffset;\n // Reanimated scrollTo is crashing on android. use 'regular' scrollTo until figured out.\n // scrollTo(scrollViewRef, targetX, targetY, true);\n runOnJS(scrollToInternal)(targetOffset);\n }, []);\n\n return null;\n}\n"],"mappings":"6FAAA,8DAMA,uCACA,qDACA,qEACA,iDAEO,QAASA,cAAT,EAAyB,cACN,GAAAC,mBAAA,GADM,CACtBC,WADsB,UACtBA,WADsB,eAM1B,GAAAC,sBAAA,GA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Ab,CAAqB2B,MAAjC,CADiB,CAEjBtB,IAAI,CAAC6B,GAAL,CACE1C,YAAY,CAACQ,KAAb,CAAqB2B,MADvB,CAEElC,cAAc,CAACO,KAAf,CAAuBN,aAAa,CAACM,KAFvC,CAFJ,CAOAW,YAAY,CAACX,KAAb,CAAqBiC,YAArB,CAGA,GAAAE,8BAAA,EAAQT,gBAAR,EAA0BO,YAA1B,EACD,CAnBD,+BA9FKhB,gBA8FL,aA1FqBR,WA0FrB,eA7FyCL,aA6FzC,kBA7F+DG,gBA6F/D,qBA5FoCnB,mBA4FpC,iBA3F0BE,eA2F1B,cA1F6FE,YA0F7F,gBA1F0HC,cA0F1H,eA1FiJC,aA0FjJ,cAzFAiB,YAyFA,SAtFAwB,8BAsFA,kBAtFQT,gBAsFR,myBAmBG,EAnBH,EAqBA,MAAO,KAAP,CACD"} \ No newline at end of file +{"version":3,"names":["useAutoScroll","useRefs","flatlistRef","useProps","autoscrollThreshold","DEFAULT_PROPS","autoscrollSpeed","useAnimatedValues","scrollOffset","scrollViewSize","containerSize","activeCellSize","hoverOffset","activeIndexAnim","hoverScreenOffset","useDerivedValue","value","isScrolledUp","SCROLL_POSITION_TOLERANCE","isScrolledDown","distToTopEdge","Math","max","distToBottomEdge","hoverPlusActiveCell","isAtTopEdge","isAtBottomEdge","scrollTarget","useSharedValue","dragIsActive","useAnimatedReaction","cur","prev","shouldAutoScroll","scrollTargetDiff","abs","hasScrolledToTarget","isAtEdge","topDisabled","bottomDisabled","isEdgeDisabled","cellIsActive","scrollToInternal","offset","current","scrollToOffset","animated","distFromEdge","speedPct","targetOffset","min","runOnJS"],"sources":["useAutoScroll.tsx"],"sourcesContent":["import {\n runOnJS,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { DEFAULT_PROPS, SCROLL_POSITION_TOLERANCE } from \"../constants\";\nimport { useProps } from \"../context/propsContext\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport { useRefs } from \"../context/refContext\";\n\nexport function useAutoScroll() {\n const { flatlistRef } = useRefs();\n\n const {\n autoscrollThreshold = DEFAULT_PROPS.autoscrollThreshold,\n autoscrollSpeed = DEFAULT_PROPS.autoscrollSpeed,\n } = useProps();\n\n const {\n scrollOffset,\n scrollViewSize,\n containerSize,\n activeCellSize,\n hoverOffset,\n activeIndexAnim,\n } = useAnimatedValues();\n\n const hoverScreenOffset = useDerivedValue(() => {\n return hoverOffset.value - scrollOffset.value;\n }, []);\n\n const isScrolledUp = useDerivedValue(() => {\n return scrollOffset.value - SCROLL_POSITION_TOLERANCE <= 0;\n }, []);\n\n const isScrolledDown = useDerivedValue(() => {\n return (\n scrollOffset.value + containerSize.value + SCROLL_POSITION_TOLERANCE >=\n scrollViewSize.value\n );\n }, []);\n\n const distToTopEdge = useDerivedValue(() => {\n return Math.max(0, hoverScreenOffset.value);\n }, []);\n\n const distToBottomEdge = useDerivedValue(() => {\n const hoverPlusActiveCell = hoverScreenOffset.value + activeCellSize.value;\n return Math.max(0, containerSize.value - hoverPlusActiveCell);\n }, []);\n\n const isAtTopEdge = useDerivedValue(() => {\n return distToTopEdge.value <= autoscrollThreshold;\n });\n\n const isAtBottomEdge = useDerivedValue(() => {\n return distToBottomEdge.value <= autoscrollThreshold;\n }, []);\n\n const scrollTarget = useSharedValue(0);\n const dragIsActive = useDerivedValue(() => {\n return activeIndexAnim.value >= 0;\n }, []);\n\n useAnimatedReaction(\n () => {\n return dragIsActive.value;\n },\n (cur, prev) => {\n if (cur && !prev) {\n scrollTarget.value = scrollOffset.value;\n }\n }\n );\n\n const shouldAutoScroll = useDerivedValue(() => {\n const scrollTargetDiff = Math.abs(scrollTarget.value - scrollOffset.value);\n const hasScrolledToTarget = scrollTargetDiff < SCROLL_POSITION_TOLERANCE;\n\n const isAtEdge = isAtTopEdge.value || isAtBottomEdge.value;\n const topDisabled = isAtTopEdge.value && isScrolledUp.value;\n const bottomDisabled = isAtBottomEdge.value && isScrolledDown.value;\n const isEdgeDisabled = topDisabled || bottomDisabled;\n\n const cellIsActive = activeIndexAnim.value >= 0;\n\n return hasScrolledToTarget && isAtEdge && !isEdgeDisabled && cellIsActive;\n }, []);\n\n function scrollToInternal(offset: number) {\n if (flatlistRef && \"current\" in flatlistRef) {\n flatlistRef.current?.scrollToOffset({ offset, animated: true });\n }\n }\n\n useDerivedValue(() => {\n if (!shouldAutoScroll.value) return;\n\n const distFromEdge = isAtTopEdge.value\n ? distToTopEdge.value\n : distToBottomEdge.value;\n const speedPct = 1 - distFromEdge / autoscrollThreshold!;\n const offset = speedPct * autoscrollSpeed;\n const targetOffset = isAtTopEdge.value\n ? Math.max(0, scrollOffset.value - offset)\n : Math.min(\n scrollOffset.value + offset,\n scrollViewSize.value - containerSize.value\n );\n\n scrollTarget.value = targetOffset;\n // Reanimated scrollTo is crashing on android. use 'regular' scrollTo until figured out.\n // scrollTo(scrollViewRef, targetX, targetY, true);\n runOnJS(scrollToInternal)(targetOffset);\n }, []);\n\n return null;\n}\n"],"mappings":"6FAAA,8DAMA,uCACA,qDACA,qEACA,iDAEO,QAASA,cAAT,EAAyB,cACN,GAAAC,mBAAA,GADM,CACtBC,WADsB,UACtBA,WADsB,eAM1B,GAAAC,sBAAA,GAN0B,iCAI5BC,mBAJ4B,CAI5BA,mBAJ4B,gCAINC,wBAAA,CAAcD,mBAJR,uDAK5BE,eAL4B,CAK5BA,eAL4B,gCAKVD,wBAAA,CAAcC,eALJ,8CAe1B,GAAAC,uCAAA,GAf0B,CAS5BC,YAT4B,oBAS5BA,YAT4B,CAU5BC,cAV4B,oBAU5BA,cAV4B,CAW5BC,aAX4B,oBAW5BA,aAX4B,CAY5BC,cAZ4B,oBAY5BA,cAZ4B,CAa5BC,WAb4B,oBAa5BA,WAb4B,CAc5BC,eAd4B,oBAc5BA,eAd4B,CAiB9B,GAAMC,kBAAiB,CAAG,GAAAC,sCAAA,iCAAsB,CAC9C,MAAOH,YAAW,CAACI,KAAZ,CAAoBR,YAAY,CAACQ,K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,kBAtFQT,gBAsFR,izBAmBG,EAnBH,EAqBA,MAAO,KAAP,CACD"} \ No newline at end of file diff --git a/lib/commonjs/hooks/useCellTranslate.js b/lib/commonjs/hooks/useCellTranslate.js index 071147e4..e9427574 100644 --- a/lib/commonjs/hooks/useCellTranslate.js +++ b/lib/commonjs/hooks/useCellTranslate.js @@ -107,7 +107,7 @@ function useCellTranslate(_ref) { "function _f(){const{cellIndex,activeIndexAnim,viewableIndexMin,viewableIndexMax,activeKey,hoverOffset,activeCellSize,cellOffset,cellSize,spacerIndexAnim,placeholderOffset,hoverAnim,withSpring,animationConfigRef}=jsThis._closure;{const isActiveCell=cellIndex===activeIndexAnim.value;const isOutsideViewableRange=!isActiveCell&&(cellIndexviewableIndexMax.value);if(!activeKey||activeIndexAnim.value<0||isOutsideViewableRange){return 0;}const isBeforeActive=cellIndexactiveIndexAnim.value;const hoverPlusActiveSize=hoverOffset.value+activeCellSize.value;const offsetPlusHalfSize=cellOffset.value+cellSize.value/2;const offsetPlusSize=cellOffset.value+cellSize.value;let result=-1;if(isAfterActive){if(hoverPlusActiveSize>=cellOffset.value&&hoverPlusActiveSize=offsetPlusHalfSize&&hoverPlusActiveSize=offsetPlusHalfSize){result=cellIndex+1;}else if(hoverOffset.value>=cellOffset.value&&hoverOffset.value=spacerIndexAnim.value;const translationAmt=shouldTranslate?activeCellSize.value*(isAfterActive?-1:1):0;return withSpring(translationAmt,animationConfigRef.current);}}"; _f.__workletHash = 883167536212; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useCellTranslate.tsx (28:36)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useCellTranslate.tsx (28:36)"; return _f; })(), [activeKey, cellIndex] diff --git a/lib/commonjs/hooks/useCellTranslate.js.map b/lib/commonjs/hooks/useCellTranslate.js.map index d08f09e8..acfe18c0 100644 --- a/lib/commonjs/hooks/useCellTranslate.js.map +++ b/lib/commonjs/hooks/useCellTranslate.js.map @@ -1 +1 @@ -{"version":3,"names":["useCellTranslate","cellIndex","cellSize","cellOffset","useAnimatedValues","activeIndexAnim","activeCellSize","hoverOffset","spacerIndexAnim","placeholderOffset","hoverAnim","viewableIndexMin","viewableIndexMax","useDraggableFlatListContext","activeKey","useRefs","animationConfigRef","translate","useDerivedValue","isActiveCell","value","isOutsideViewableRange","isBeforeActive","isAfterActive","hoverPlusActiveSize","offsetPlusHalfSize","offsetPlusSize","result","newPlaceholderOffset","shouldTranslate","translationAmt","withSpring","current"],"sources":["useCellTranslate.tsx"],"sourcesContent":["import Animated, { useDerivedValue, withSpring } from \"react-native-reanimated\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { useRefs } from \"../context/refContext\";\n\ntype Params = {\n cellIndex: number;\n cellSize: Animated.SharedValue;\n cellOffset: Animated.SharedValue;\n};\n\nexport function useCellTranslate({ cellIndex, cellSize, cellOffset }: Params) {\n const {\n activeIndexAnim,\n activeCellSize,\n hoverOffset,\n spacerIndexAnim,\n placeholderOffset,\n hoverAnim,\n viewableIndexMin,\n viewableIndexMax,\n } = useAnimatedValues();\n\n const { activeKey } = useDraggableFlatListContext();\n\n const { animationConfigRef } = useRefs();\n\n const translate = useDerivedValue(() => {\n const isActiveCell = cellIndex === activeIndexAnim.value;\n const isOutsideViewableRange =\n !isActiveCell &&\n (cellIndex < viewableIndexMin.value ||\n cellIndex > viewableIndexMax.value);\n if (!activeKey || activeIndexAnim.value < 0 || isOutsideViewableRange) {\n return 0;\n }\n\n // Determining spacer index is hard to visualize. See diagram: https://i.imgur.com/jRPf5t3.jpg\n const isBeforeActive = cellIndex < activeIndexAnim.value;\n const isAfterActive = cellIndex > activeIndexAnim.value;\n\n const hoverPlusActiveSize = hoverOffset.value + activeCellSize.value;\n const offsetPlusHalfSize = cellOffset.value + cellSize.value / 2;\n const offsetPlusSize = cellOffset.value + cellSize.value;\n let result = -1;\n\n if (isAfterActive) {\n if (\n hoverPlusActiveSize >= cellOffset.value &&\n hoverPlusActiveSize < offsetPlusHalfSize\n ) {\n // bottom edge of active cell overlaps top half of current cell\n result = cellIndex - 1;\n } else if (\n hoverPlusActiveSize >= offsetPlusHalfSize &&\n hoverPlusActiveSize < offsetPlusSize\n ) {\n // bottom edge of active cell overlaps bottom half of current cell\n result = cellIndex;\n }\n } else if (isBeforeActive) {\n if (\n hoverOffset.value < offsetPlusSize &&\n hoverOffset.value >= offsetPlusHalfSize\n ) {\n // top edge of active cell overlaps bottom half of current cell\n result = cellIndex + 1;\n } else if (\n hoverOffset.value >= cellOffset.value &&\n hoverOffset.value < offsetPlusHalfSize\n ) {\n // top edge of active cell overlaps top half of current cell\n result = cellIndex;\n }\n }\n\n if (result !== -1 && result !== spacerIndexAnim.value) {\n spacerIndexAnim.value = result;\n }\n\n if (spacerIndexAnim.value === cellIndex) {\n const newPlaceholderOffset = isAfterActive\n ? cellSize.value + (cellOffset.value - activeCellSize.value)\n : cellOffset.value;\n placeholderOffset.value = newPlaceholderOffset;\n }\n\n // Active cell follows touch\n if (isActiveCell) {\n return hoverAnim.value;\n }\n\n // Translate cell down if it is before active index and active cell has passed it.\n // Translate cell up if it is after the active index and active cell has passed it.\n\n const shouldTranslate = isAfterActive\n ? cellIndex <= spacerIndexAnim.value\n : cellIndex >= spacerIndexAnim.value;\n\n const translationAmt = shouldTranslate\n ? activeCellSize.value * (isAfterActive ? -1 : 1)\n : 0;\n\n return withSpring(translationAmt, animationConfigRef.current);\n }, [activeKey, cellIndex]);\n\n return translate;\n}\n"],"mappings":"mGAAA,8DACA,qEACA,6EACA,iDAQO,QAASA,iBAAT,MAAuE,IAA3CC,UAA2C,MAA3CA,SAA2C,CAAhCC,QAAgC,MAAhCA,QAAgC,CAAtBC,UAAsB,MAAtBA,UAAsB,wBAUxE,GAAAC,uCAAA,GAVwE,CAE1EC,eAF0E,oBAE1EA,eAF0E,CAG1EC,cAH0E,oBAG1EA,cAH0E,CAI1EC,WAJ0E,oBAI1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D/B,SAxB3D,iBAhBgBI,eAgBhB,kBAxB2CM,gBAwB3C,kBAxBiFC,gBAwBjF,WAtBbE,SAsBa,aAEoCP,WAFpC,gBAyBuBD,cAzBvB,YAa0FH,UAb1F,UAa6BD,QAb7B,iBAwBwEM,eAxBxE,mBAchBC,iBAdgB,WAmBTC,SAnBS,YA0BXqB,iCA1BW,6BA0BgBf,kBAAkB,CAACgB,OA1BnC,i5DA6Ef,CAAClB,SAAD,CAAYb,SAAZ,CA7Ee,CAAlB,CA+EA,MAAOgB,UAAP,CACD"} \ No newline at end of file +{"version":3,"names":["useCellTranslate","cellIndex","cellSize","cellOffset","useAnimatedValues","activeIndexAnim","activeCellSize","hoverOffset","spacerIndexAnim","placeholderOffset","hoverAnim","viewableIndexMin","viewableIndexMax","useDraggableFlatListContext","activeKey","useRefs","animationConfigRef","translate","useDerivedValue","isActiveCell","value","isOutsideViewableRange","isBeforeActive","isAfterActive","hoverPlusActiveSize","offsetPlusHalfSize","offsetPlusSize","result","newPlaceholderOffset","shouldTranslate","translationAmt","withSpring","current"],"sources":["useCellTranslate.tsx"],"sourcesContent":["import Animated, { useDerivedValue, withSpring } from \"react-native-reanimated\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { useRefs } from \"../context/refContext\";\n\ntype Params = {\n cellIndex: number;\n cellSize: Animated.SharedValue;\n cellOffset: Animated.SharedValue;\n};\n\nexport function useCellTranslate({ cellIndex, cellSize, cellOffset }: Params) {\n const {\n activeIndexAnim,\n activeCellSize,\n hoverOffset,\n spacerIndexAnim,\n placeholderOffset,\n hoverAnim,\n viewableIndexMin,\n viewableIndexMax,\n } = useAnimatedValues();\n\n const { activeKey } = useDraggableFlatListContext();\n\n const { animationConfigRef } = useRefs();\n\n const translate = useDerivedValue(() => {\n const isActiveCell = cellIndex === activeIndexAnim.value;\n const isOutsideViewableRange =\n !isActiveCell &&\n (cellIndex < viewableIndexMin.value ||\n cellIndex > viewableIndexMax.value);\n if (!activeKey || activeIndexAnim.value < 0 || isOutsideViewableRange) {\n return 0;\n }\n\n // Determining spacer index is hard to visualize. See diagram: https://i.imgur.com/jRPf5t3.jpg\n const isBeforeActive = cellIndex < activeIndexAnim.value;\n const isAfterActive = cellIndex > activeIndexAnim.value;\n\n const hoverPlusActiveSize = hoverOffset.value + activeCellSize.value;\n const offsetPlusHalfSize = cellOffset.value + cellSize.value / 2;\n const offsetPlusSize = cellOffset.value + cellSize.value;\n let result = -1;\n\n if (isAfterActive) {\n if (\n hoverPlusActiveSize >= cellOffset.value &&\n hoverPlusActiveSize < offsetPlusHalfSize\n ) {\n // bottom edge of active cell overlaps top half of current cell\n result = cellIndex - 1;\n } else if (\n hoverPlusActiveSize >= offsetPlusHalfSize &&\n hoverPlusActiveSize < offsetPlusSize\n ) {\n // bottom edge of active cell overlaps bottom half of current cell\n result = cellIndex;\n }\n } else if (isBeforeActive) {\n if (\n hoverOffset.value < offsetPlusSize &&\n hoverOffset.value >= offsetPlusHalfSize\n ) {\n // top edge of active cell overlaps bottom half of current cell\n result = cellIndex + 1;\n } else if (\n hoverOffset.value >= cellOffset.value &&\n hoverOffset.value < offsetPlusHalfSize\n ) {\n // top edge of active cell overlaps top half of current cell\n result = cellIndex;\n }\n }\n\n if (result !== -1 && result !== spacerIndexAnim.value) {\n spacerIndexAnim.value = result;\n }\n\n if (spacerIndexAnim.value === cellIndex) {\n const newPlaceholderOffset = isAfterActive\n ? cellSize.value + (cellOffset.value - activeCellSize.value)\n : cellOffset.value;\n placeholderOffset.value = newPlaceholderOffset;\n }\n\n // Active cell follows touch\n if (isActiveCell) {\n return hoverAnim.value;\n }\n\n // Translate cell down if it is before active index and active cell has passed it.\n // Translate cell up if it is after the active index and active cell has passed it.\n\n const shouldTranslate = isAfterActive\n ? cellIndex <= spacerIndexAnim.value\n : cellIndex >= spacerIndexAnim.value;\n\n const translationAmt = shouldTranslate\n ? activeCellSize.value * (isAfterActive ? -1 : 1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AjB,CACD,CAKD,GAAMS,gBAAe,CAAGN,aAAa,CACjCtB,SAAS,EAAIO,eAAe,CAACY,KADI,CAEjCnB,SAAS,EAAIO,eAAe,CAACY,KAFjC,CAIA,GAAMU,eAAc,CAAGD,eAAe,CAClCvB,cAAc,CAACc,KAAf,EAAwBG,aAAa,CAAG,CAAC,CAAJ,CAAQ,CAA7C,CADkC,CAElC,CAFJ,CAIA,MAAO,GAAAQ,iCAAA,EAAWD,cAAX,CAA2Bd,kBAAkB,CAACgB,OAA9C,CAAP,CACD,CA7EiB,wBAwB2D/B,SAxB3D,iBAhBgBI,eAgBhB,kBAxB2CM,gBAwB3C,kBAxBiFC,gBAwBjF,WAtBbE,SAsBa,aAEoCP,WAFpC,gBAyBuBD,cAzBvB,YAa0FH,UAb1F,UAa6BD,QAb7B,iBAwBwEM,eAxBxE,mBAchBC,iBAdgB,WAmBTC,SAnBS,YA0BXqB,iCA1BW,6BA0BgBf,kBAAkB,CAACgB,OA1BnC,+5DA6Ef,CAAClB,SAAD,CAAYb,SAAZ,CA7Ee,CAAlB,CA+EA,MAAOgB,UAAP,CACD"} \ No newline at end of file diff --git a/lib/commonjs/hooks/useNestedAutoScroll.js b/lib/commonjs/hooks/useNestedAutoScroll.js index 433e4f4d..cd02ad7e 100644 --- a/lib/commonjs/hooks/useNestedAutoScroll.js +++ b/lib/commonjs/hooks/useNestedAutoScroll.js @@ -42,7 +42,7 @@ function useNestedAutoScroll(params) { "function _f(){const{hoverOffset,outerScrollOffset}=jsThis._closure;{return hoverOffset.value-outerScrollOffset.value;}}"; _f.__workletHash = 11717240117335; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (45:44)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (45:44)"; return _f; })(), [] @@ -62,7 +62,7 @@ function useNestedAutoScroll(params) { "function _f(){const{outerScrollOffset,SCROLL_POSITION_TOLERANCE}=jsThis._closure;{return outerScrollOffset.value-SCROLL_POSITION_TOLERANCE<=0;}}"; _f.__workletHash = 10747505363427; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (49:39)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (49:39)"; return _f; })(), [] @@ -87,7 +87,7 @@ function useNestedAutoScroll(params) { "function _f(){const{outerScrollOffset,containerSize,SCROLL_POSITION_TOLERANCE,scrollViewSize}=jsThis._closure;{return outerScrollOffset.value+containerSize.value+SCROLL_POSITION_TOLERANCE>=scrollViewSize.value;}}"; _f.__workletHash = 11318153912380; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (53:41)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (53:41)"; return _f; })(), [] @@ -102,7 +102,7 @@ function useNestedAutoScroll(params) { "function _f(){const{hoverScreenOffset}=jsThis._closure;{return Math.max(0,hoverScreenOffset.value);}}"; _f.__workletHash = 5945680760068; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (60:40)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (60:40)"; return _f; })(), [hoverScreenOffset] @@ -124,7 +124,7 @@ function useNestedAutoScroll(params) { "function _f(){const{containerSize,hoverScreenOffset,activeCellSize}=jsThis._closure;{const dist=containerSize.value-(hoverScreenOffset.value+activeCellSize.value);return Math.max(0,dist);}}"; _f.__workletHash = 11179566731136; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (64:43)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (64:43)"; return _f; })(), [hoverScreenOffset, activeCellSize, containerSize] @@ -142,7 +142,7 @@ function useNestedAutoScroll(params) { "function _f(){const{distToTopEdge,autoscrollThreshold}=jsThis._closure;{return distToTopEdge.value<=autoscrollThreshold;}}"; _f.__workletHash = 499688299934; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (69:38)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (69:38)"; return _f; })(), [] @@ -160,7 +160,7 @@ function useNestedAutoScroll(params) { "function _f(){const{distToBottomEdge,autoscrollThreshold}=jsThis._closure;{return distToBottomEdge.value<=autoscrollThreshold;}}"; _f.__workletHash = 10361122491518; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (73:41)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (73:41)"; return _f; })() ); @@ -175,7 +175,7 @@ function useNestedAutoScroll(params) { "function _f(){const{isDraggingCell}=jsThis._closure;{return isDraggingCell.value;}}"; _f.__workletHash = 15902771485203; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (80:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (80:4)"; return _f; })(), (function () { @@ -192,7 +192,7 @@ function useNestedAutoScroll(params) { "function _f(cur,prev){const{scrollTarget,outerScrollOffset}=jsThis._closure;{if(cur&&!prev){scrollTarget.value=outerScrollOffset.value;}}}"; _f.__workletHash = 5863730252712; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (83:4)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (83:4)"; return _f; })(), [activeCellSize] @@ -255,7 +255,7 @@ function useNestedAutoScroll(params) { "function _f(){const{isAtTopEdge,isAtBottomEdge,isScrolledUp,isScrolledDown,scrollTarget,outerScrollOffset,SCROLL_POSITION_TOLERANCE,isDraggingCell,isTouchActiveNative,distToTopEdge,distToBottomEdge,autoscrollThreshold,autoscrollSpeed,runOnJS,scrollToInternal}=jsThis._closure;{const isAtEdge=isAtTopEdge.value||isAtBottomEdge.value;const topDisabled=isAtTopEdge.value&&isScrolledUp.value;const bottomDisabled=isAtBottomEdge.value&&isScrolledDown.value;const isEdgeDisabled=topDisabled||bottomDisabled;const scrollTargetDiff=Math.abs(scrollTarget.value-outerScrollOffset.value);const scrollInProgress=scrollTargetDiff>SCROLL_POSITION_TOLERANCE;const shouldScroll=isAtEdge&&!isEdgeDisabled&&isDraggingCell.value&&isTouchActiveNative.value&&!scrollInProgress;const distFromEdge=isAtTopEdge.value?distToTopEdge.value:distToBottomEdge.value;const speedPct=1-distFromEdge/autoscrollThreshold;const offset=speedPct*autoscrollSpeed;const targetOffset=isAtTopEdge.value?Math.max(0,outerScrollOffset.value-offset):outerScrollOffset.value+offset;if(shouldScroll){scrollTarget.value=targetOffset;runOnJS(scrollToInternal)(targetOffset);}}}"; _f.__workletHash = 3348905696169; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (95:18)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useNestedAutoScroll.tsx (95:18)"; return _f; })(), [autoscrollSpeed, autoscrollThreshold, isDraggingCell] diff --git a/lib/commonjs/hooks/useNestedAutoScroll.js.map b/lib/commonjs/hooks/useNestedAutoScroll.js.map index 0ae62170..376ccf05 100644 --- a/lib/commonjs/hooks/useNestedAutoScroll.js.map +++ b/lib/commonjs/hooks/useNestedAutoScroll.js.map @@ -1 +1 @@ -{"version":3,"names":["useNestedAutoScroll","params","useSafeNestableScrollContainerContext","outerScrollOffset","containerSize","scrollableRef","scrollViewSize","DUMMY_VAL","useSharedValue","hoverOffset","activeCellSize","autoscrollSpeed","autoscrollThreshold","isDraggingCell","isTouchActiveNative","hoverScreenOffset","useDerivedValue","value","isScrolledUp","SCROLL_POSITION_TOLERANCE","isScrolledDown","distToTopEdge","Math","max","distToBottomEdge","dist","isAtTopEdge","isAtBottomEdge","scrollTarget","useAnimatedReaction","cur","prev","scrollToInternal","y","current","scrollTo","animated","isAtEdge","topDisabled","bottomDisabled","isEdgeDisabled","scrollTargetDiff","abs","scrollInProgress","shouldScroll","distFromEdge","speedPct","offset","targetOffset","runOnJS"],"sources":["useNestedAutoScroll.tsx"],"sourcesContent":["import Animated, {\n runOnJS,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { State as GestureState } from \"react-native-gesture-handler\";\nimport { useSafeNestableScrollContainerContext } from \"../context/nestableScrollContainerContext\";\nimport { SCROLL_POSITION_TOLERANCE } from \"../constants\";\n\n// This is mostly copied over from the main react-native-draggable-flatlist\n// useAutoScroll hook with a few notable exceptions:\n// - Since animated values are now coming in via a callback,\n// we won't guarantee they exist (and default them if not).\n// - Outer scrollable is a ScrollView, not a FlatList\n// TODO: see if we can combine into a single shared `useAutoScroll()` hook\n\nexport function useNestedAutoScroll(params: {\n activeCellSize?: Animated.SharedValue;\n autoscrollSpeed?: number;\n autoscrollThreshold?: number;\n hoverOffset?: Animated.SharedValue;\n isDraggingCell?: Animated.SharedValue;\n isTouchActiveNative?: Animated.SharedValue;\n panGestureState?: Animated.SharedValue;\n}) {\n const {\n outerScrollOffset,\n containerSize,\n scrollableRef,\n scrollViewSize,\n } = useSafeNestableScrollContainerContext();\n\n const DUMMY_VAL = useSharedValue(0);\n\n const {\n hoverOffset = DUMMY_VAL,\n activeCellSize = DUMMY_VAL,\n autoscrollSpeed = 100,\n autoscrollThreshold = 30,\n isDraggingCell = DUMMY_VAL,\n isTouchActiveNative = DUMMY_VAL,\n } = params;\n\n const hoverScreenOffset = useDerivedValue(() => {\n return hoverOffset.value - outerScrollOffset.value;\n }, []);\n\n const isScrolledUp = useDerivedValue(() => {\n return outerScrollOffset.value - SCROLL_POSITION_TOLERANCE <= 0;\n }, []);\n\n const isScrolledDown = useDerivedValue(() => {\n return (\n outerScrollOffset.value + containerSize.value + SCROLL_POSITION_TOLERANCE >=\n scrollViewSize.value\n );\n }, []);\n\n const distToTopEdge = useDerivedValue(() => {\n return Math.max(0, hoverScreenOffset.value);\n }, [hoverScreenOffset]);\n\n const distToBottomEdge = useDerivedValue(() => {\n const dist = containerSize.value - (hoverScreenOffset.value + activeCellSize.value)\n return Math.max(0, dist);\n }, [hoverScreenOffset, activeCellSize, containerSize]);\n\n const isAtTopEdge = useDerivedValue(() => {\n return distToTopEdge.value <= autoscrollThreshold;\n }, []);\n\n const isAtBottomEdge = useDerivedValue(() => {\n return distToBottomEdge.value <= autoscrollThreshold;\n });\n\n const scrollTarget = useSharedValue(0);\n\n useAnimatedReaction(\n () => {\n return isDraggingCell.value;\n },\n (cur, prev) => {\n if (cur && !prev) {\n scrollTarget.value = outerScrollOffset.value;\n }\n },\n [activeCellSize]\n );\n\n function scrollToInternal(y: number) {\n scrollableRef.current?.scrollTo({ y, animated: true });\n }\n\n useDerivedValue(() => {\n const isAtEdge = isAtTopEdge.value || isAtBottomEdge.value;\n const topDisabled = isAtTopEdge.value && isScrolledUp.value;\n const bottomDisabled = isAtBottomEdge.value && isScrolledDown.value;\n const isEdgeDisabled = topDisabled || bottomDisabled;\n\n const scrollTargetDiff = Math.abs(scrollTarget.value - outerScrollOffset.value);\n const scrollInProgress = scrollTargetDiff > SCROLL_POSITION_TOLERANCE;\n\n const shouldScroll =\n isAtEdge &&\n !isEdgeDisabled &&\n isDraggingCell.value &&\n isTouchActiveNative.value &&\n !scrollInProgress;\n\n const distFromEdge = isAtTopEdge.value\n ? distToTopEdge.value\n : distToBottomEdge.value;\n const speedPct = 1 - distFromEdge / autoscrollThreshold;\n const offset = speedPct * autoscrollSpeed;\n const targetOffset = isAtTopEdge.value\n ? Math.max(0, outerScrollOffset.value - offset)\n : outerScrollOffset.value + offset;\n if (shouldScroll) {\n scrollTarget.value = targetOffset;\n // Reanimated scrollTo is crashing on android. use 'regular' scrollTo until figured out.\n // scrollTo(scrollViewRef, 0, scrollTar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MAAtC,CADiB,CAEjB5C,iBAAiB,CAACc,KAAlB,CAA0B8B,MAF9B,CAGA,GAAIH,YAAJ,CAAkB,CAChBhB,YAAY,CAACX,KAAb,CAAqB+B,YAArB,CAGA,GAAAC,8BAAA,EAAQjB,gBAAR,EAA0BgB,YAA1B,EACD,CACF,CA9BD,0BAlFqBtB,WAkFrB,gBA1FuBC,cA0FvB,cA3FyCT,YA2FzC,gBA1F+CE,cA0F/C,cA/EEQ,YA+EF,mBAlFyFzB,iBAkFzF,2BAvF4CgB,oCAuF5C,gBAtFoDN,cAsFpD,qBAtF4EC,mBAsF5E,eArFyCO,aAqFzC,kBArF+DG,gBAqF/D,qBApFoCZ,mBAoFpC,iBAnF0BD,eAmF1B,SA5EEsC,8BA4EF,kBA5EUjB,gBA4EV,8wCA8BG,CAACrB,eAAD,CAAkBC,mBAAlB,CAAuCC,cAAvC,CA9BH,EAgCA,MAAO,KAAP,CACD"} \ No newline at end of file +{"version":3,"names":["useNestedAutoScroll","params","useSafeNestableScrollContainerContext","outerScrollOffset","containerSize","scrollableRef","scrollViewSize","DUMMY_VAL","useSharedValue","hoverOffset","activeCellSize","autoscrollSpeed","autoscrollThreshold","isDraggingCell","isTouchActiveNative","hoverScreenOffset","useDerivedValue","value","isScrolledUp","SCROLL_POSITION_TOLERANCE","isScrolledDown","distToTopEdge","Math","max","distToBottomEdge","dist","isAtTopEdge","isAtBottomEdge","scrollTarget","useAnimatedReaction","cur","prev","scrollToInternal","y","current","scrollTo","animated","isAtEdge","topDisabled","bottomDisabled","isEdgeDisabled","scrollTargetDiff","abs","scrollInProgress","shouldScroll","distFromEdge","speedPct","offset","targetOffset","runOnJS"],"sources":["useNestedAutoScroll.tsx"],"sourcesContent":["import Animated, {\n runOnJS,\n useAnimatedReaction,\n useDerivedValue,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { State as GestureState } from \"react-native-gesture-handler\";\nimport { useSafeNestableScrollContainerContext } from \"../context/nestableScrollContainerContext\";\nimport { SCROLL_POSITION_TOLERANCE } from \"../constants\";\n\n// This is mostly copied over from the main react-native-draggable-flatlist\n// useAutoScroll hook with a few notable exceptions:\n// - Since animated values are now coming in via a callback,\n// we won't guarantee they exist (and default them if not).\n// - Outer scrollable is a ScrollView, not a FlatList\n// TODO: see if we can combine into a single shared `useAutoScroll()` hook\n\nexport function useNestedAutoScroll(params: {\n activeCellSize?: Animated.SharedValue;\n autoscrollSpeed?: number;\n autoscrollThreshold?: number;\n hoverOffset?: Animated.SharedValue;\n isDraggingCell?: Animated.SharedValue;\n isTouchActiveNative?: Animated.SharedValue;\n panGestureState?: Animated.SharedValue;\n}) {\n const {\n outerScrollOffset,\n containerSize,\n scrollableRef,\n scrollViewSize,\n } = useSafeNestableScrollContainerContext();\n\n const DUMMY_VAL = useSharedValue(0);\n\n const {\n hoverOffset = DUMMY_VAL,\n activeCellSize = DUMMY_VAL,\n autoscrollSpeed = 100,\n autoscrollThreshold = 30,\n isDraggingCell = DUMMY_VAL,\n isTouchActiveNative = DUMMY_VAL,\n } = params;\n\n const hoverScreenOffset = useDerivedValue(() => {\n return hoverOffset.value - outerScrollOffset.value;\n }, []);\n\n const isScrolledUp = useDerivedValue(() => {\n return outerScrollOffset.value - SCROLL_POSITION_TOLERANCE <= 0;\n }, []);\n\n const isScrolledDown = useDerivedValue(() => {\n return (\n outerScrollOffset.value + containerSize.value + SCROLL_POSITION_TOLERANCE >=\n scrollViewSize.value\n );\n }, []);\n\n const distToTopEdge = useDerivedValue(() => {\n return Math.max(0, hoverScreenOffset.value);\n }, [hoverScreenOffset]);\n\n const distToBottomEdge = useDerivedValue(() => {\n const dist = containerSize.value - (hoverScreenOffset.value + activeCellSize.value)\n return Math.max(0, dist);\n }, [hoverScreenOffset, activeCellSize, containerSize]);\n\n const isAtTopEdge = useDerivedValue(() => {\n return distToTopEdge.value <= autoscrollThreshold;\n }, []);\n\n const isAtBottomEdge = useDerivedValue(() => {\n return distToBottomEdge.value <= autoscrollThreshold;\n });\n\n const scrollTarget = useSharedValue(0);\n\n useAnimatedReaction(\n () => {\n return isDraggingCell.value;\n },\n (cur, prev) => {\n if (cur && !prev) {\n scrollTarget.value = outerScrollOffset.value;\n }\n },\n [activeCellSize]\n );\n\n function scrollToInternal(y: number) {\n scrollableRef.current?.scrollTo({ y, animated: true });\n }\n\n useDerivedValue(() => {\n const isAtEdge = isAtTopEdge.value || isAtBottomEdge.value;\n const topDisabled = isAtTopEdge.value && isScrolledUp.value;\n const bottomDisabled = isAtBottomEdge.value && isScrolledDown.value;\n const isEdgeDisabled = topDisabled || bottomDisabled;\n\n const scrollTargetDiff = Math.abs(scrollTarget.value - outerScrollOffset.value);\n const scrollInProgress = scrollTargetDiff > SCROLL_POSITION_TOLERANCE;\n\n const shouldScroll =\n isAtEdge &&\n !isEdgeDisabled &&\n isDraggingCell.value &&\n isTouchActiveNative.value &&\n !scrollInProgress;\n\n const distFromEdge = isAtTopEdge.value\n ? distToTopEdge.value\n : distToBottomEdge.value;\n const speedPct = 1 - distFromEdge / autoscrollThreshold;\n const offset = speedPct * autoscrollSpeed;\n const targetOffset = isAtTopEdge.value\n ? Math.max(0, outerScrollOffset.value - offset)\n : outerScrollOffset.value + offset;\n if (shouldScroll) {\n scrollTarget.value = targetOffset;\n // Reanimated scrollTo is crashing on android. use 'regular' scrollTo until figured out.\n // scrollTo(scrollViewRef, 0, scrollTarget.value, true)\n runOnJS(scrollToInternal)(targetOffset);\n }\n }, [autoscrollSpeed, autoscrollThreshold, isDraggingCell]);\n\n return null;\n}\n"],"mappings":"yGAAA,8DAOA,yFACA,uCASO,QAASA,oBAAT,CAA6BC,MAA7B,CAQJ,2BAMG,GAAAC,qEAAA,GANH,CAECC,iBAFD,uBAECA,iBAFD,CAGCC,aAHD,uBAGCA,aAHD,CAICC,aAJD,uBAICA,aAJD,CAKCC,cALD,uBAKCA,cALD,CAQD,GAAMC,UAAS,CAAG,GAAAC,qCAAA,EAAe,CAAf,CAAlB,CARC,wBAiBGP,MAjBH,CAWCQ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aAqFzC,kBArF+DG,gBAqF/D,qBApFoCZ,mBAoFpC,iBAnF0BD,eAmF1B,SA5EEsC,8BA4EF,kBA5EUjB,gBA4EV,4xCA8BG,CAACrB,eAAD,CAAkBC,mBAAlB,CAAuCC,cAAvC,CA9BH,EAgCA,MAAO,KAAP,CACD"} \ No newline at end of file diff --git a/lib/commonjs/hooks/useOnCellActiveAnimation.js b/lib/commonjs/hooks/useOnCellActiveAnimation.js index 921791c0..db71ed0f 100644 --- a/lib/commonjs/hooks/useOnCellActiveAnimation.js +++ b/lib/commonjs/hooks/useOnCellActiveAnimation.js @@ -40,7 +40,7 @@ function useOnCellActiveAnimation() { "function _f(){const{isActive,isTouchActiveNative,withSpring,DEFAULT_ANIMATION_CONFIG,animationConfigRef}=jsThis._closure;{const toVal=isActive&&isTouchActiveNative.value?1:0;return withSpring(toVal,{...DEFAULT_ANIMATION_CONFIG,...animationConfigRef.current});}}"; _f.__workletHash = 6336668549172; _f.__location = - "/Users/cs/Code/react-native-draggable-flatlist/src/hooks/useOnCellActiveAnimation.ts (25:39)"; + "/Users/harveyappleton/GitHub/react-native-draggable-flatlist/src/hooks/useOnCellActiveAnimation.ts (25:39)"; return _f; })(), [isActive] diff --git a/lib/commonjs/hooks/useOnCellActiveAnimation.js.map b/lib/commonjs/hooks/useOnCellActiveAnimation.js.map index 239e159b..a6a6d5ef 100644 --- a/lib/commonjs/hooks/useOnCellActiveAnimation.js.map +++ b/lib/commonjs/hooks/useOnCellActiveAnimation.js.map @@ -1 +1 @@ -{"version":3,"names":["useOnCellActiveAnimation","animationConfig","animationConfigRef","useRef","current","isActive","useIsActive","useAnimatedValues","isTouchActiveNative","onActiveAnim","useDerivedValue","toVal","value","withSpring","DEFAULT_ANIMATION_CONFIG"],"sources":["useOnCellActiveAnimation.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport Animated, {\n useDerivedValue,\n withSpring,\n WithSpringConfig,\n} from \"react-native-reanimated\";\nimport { DEFAULT_ANIMATION_CONFIG } from \"../constants\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport { useIsActive } from \"../context/cellContext\";\n\ntype Params = {\n animationConfig: Partial;\n};\n\nexport function useOnCellActiveAnimation(\n { animationConfig }: Params = { animationConfig: {} }\n) {\n const animationConfigRef = useRef(animationConfig);\n animationConfigRef.current = animationConfig;\n\n const isActive = useIsActive();\n\n const { isTouchActiveNative } = useAnimatedValues();\n\n const onActiveAnim = useDerivedValue(() => {\n const toVal = isActive && isTouchActiveNative.value ? 1 : 0;\n return withSpring(toVal, {\n ...DEFAULT_ANIMATION_CONFIG,\n ...animationConfigRef.current,\n });\n }, [isActive]);\n\n return {\n isActive,\n onActiveAnim,\n };\n}\n"],"mappings":"mHAAA,4BACA,8DAKA,uCACA,qEACA,mDAMO,QAASA,yBAAT,EAEL,oEAD8B,CAAEC,eAAe,CAAE,EAAnB,CAC9B,CADEA,eACF,MADEA,eACF,CACA,GAAMC,mBAAkB,CAAG,GAAAC,aAAA,EAAOF,eAAP,CAA3B,CACAC,kBAAkB,CAACE,OAAnB,CAA6BH,eAA7B,CAEA,GAAMI,SAAQ,CAAG,GAAAC,wBAAA,GAAjB,CAJA,uBAMgC,GAAAC,uCAAA,GANhC,CAMQC,mBANR,oBAMQA,mBANR,CAQA,GAAMC,aAAY,CAAG,GAAAC,sCAAA,iCAAsB,CACzC,GAAMC,MAAK,CAAGN,QAAQ,EAAIG,mBAAmB,CAACI,KAAhC,CAAwC,CAAxC,CAA4C,CAA1D,CACA,MAAO,GAAAC,iCAAA,EAAWF,KAAX,kBACFG,mCADE,CAEFZ,kBAAkB,CAACE,OAFjB,EAAP,CAID,CANoB,uBAtBPC,QAsBO,qBAtBKG,mBAsBL,YArBdK,iCAqBc,0BArBSC,mCAqBT,6BApBhBZ,kBAAkB,CAACE,OAoBH,ibAMlB,CAACC,QAAD,CANkB,CAArB,CAQA,MAAO,CACLA,QAAQ,CAARA,QADK,CAELI,YAAY,CAAZA,YAFK,CAAP,CAID"} \ No newline at end of file +{"version":3,"names":["useOnCellActiveAnimation","animationConfig","animationConfigRef","useRef","current","isActive","useIsActive","useAnimatedValues","isTouchActiveNative","onActiveAnim","useDerivedValue","toVal","value","withSpring","DEFAULT_ANIMATION_CONFIG"],"sources":["useOnCellActiveAnimation.ts"],"sourcesContent":["import { useRef } from \"react\";\nimport Animated, {\n useDerivedValue,\n withSpring,\n WithSpringConfig,\n} from \"react-native-reanimated\";\nimport { DEFAULT_ANIMATION_CONFIG } from \"../constants\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport { useIsActive } from \"../context/cellContext\";\n\ntype Params = {\n animationConfig: Partial;\n};\n\nexport function useOnCellActiveAnimation(\n { animationConfig }: Params = { animationConfig: {} }\n) {\n const animationConfigRef = useRef(animationConfig);\n animationConfigRef.current = animationConfig;\n\n const isActive = useIsActive();\n\n const { isTouchActiveNative } = useAnimatedValues();\n\n const onActiveAnim = useDerivedValue(() => {\n const toVal = isActive && isTouchActiveNative.value ? 1 : 0;\n return withSpring(toVal, {\n ...DEFAULT_ANIMATION_CONFIG,\n ...animationConfigRef.current,\n });\n }, [isActive]);\n\n return {\n isActive,\n onActiveAnim,\n };\n}\n"],"mappings":"mHAAA,4BACA,8DAKA,uCACA,qEACA,mDAMO,QAASA,yBAAT,EAEL,oEAD8B,CAAEC,eAAe,CAAE,EAAnB,CAC9B,CADEA,eACF,MADEA,eACF,CACA,GAAMC,mBAAkB,CAAG,GAAAC,aAAA,EAAOF,eAAP,CAA3B,CACAC,kBAAkB,CAACE,OAAnB,CAA6BH,eAA7B,CAEA,GAAMI,SAAQ,CAAG,GAAAC,wBAAA,GAAjB,CAJA,uBAMgC,GAAAC,uCAAA,GANhC,CAMQC,mBANR,oBAMQA,mBANR,CAQA,GAAMC,aAAY,CAAG,GAAAC,sCAAA,iCAAsB,CACzC,GAAMC,MAAK,CAAGN,QAAQ,EAAIG,mBAAmB,CAACI,KAAhC,CAAwC,CAAxC,CAA4C,CAA1D,CACA,MAAO,GAAAC,iCAAA,EAAWF,KAAX,kBACFG,mCADE,CAEFZ,kBAAkB,CAACE,OAFjB,EAAP,CAID,CANoB,uBAtBPC,QAsBO,qBAtBKG,mBAsBL,YArBdK,iCAqBc,0BArBSC,mCAqBT,6BApBhBZ,kBAAkB,CAACE,OAoBH,+bAMlB,CAACC,QAAD,CANkB,CAArB,CAQA,MAAO,CACLA,QAAQ,CAARA,QADK,CAELI,YAAY,CAAZA,YAFK,CAAP,CAID"} \ No newline at end of file diff --git a/lib/module/components/CellRendererComponent.js b/lib/module/components/CellRendererComponent.js index dab0ae4b..34b0a4e3 100644 --- a/lib/module/components/CellRendererComponent.js +++ b/lib/module/components/CellRendererComponent.js @@ -16,7 +16,7 @@ function _extends() { } import React, { useEffect, useMemo, useRef } from "react"; -import { findNodeHandle, StyleSheet } from "react-native"; +import { findNodeHandle } from "react-native"; import Animated, { runOnUI, useAnimatedStyle, @@ -61,7 +61,7 @@ function CellRendererComponent(props) { heldTanslate.value = translate.value; } - const t = activeKey ? translate.value : heldTanslate.value; + const t = isWeb ? translate.value : heldTanslate.value; return { transform: [ horizontalAnim.value @@ -111,11 +111,12 @@ function CellRendererComponent(props) { } }); const onCellLayout = useStableCallback((e) => { - heldTanslate.value = 0; updateCellMeasurements(); if (onLayout && e) onLayout(e); }); useEffect(() => { + heldTanslate.value = 0; + if (isWeb) { // onLayout isn't called on web when the cell index changes, so we manually re-measure requestAnimationFrame(() => { @@ -168,11 +169,7 @@ function CellRendererComponent(props) { layout: propsRef.current.enableLayoutAnimationExperimental ? itemLayoutAnimation : undefined, - style: [ - props.style, - baseStyle, - activeKey ? animStyle : styles.zeroTranslate, - ], + style: [props.style, baseStyle, animStyle], pointerEvents: activeKey ? "none" : "auto", }), /*#__PURE__*/ React.createElement( @@ -186,18 +183,6 @@ function CellRendererComponent(props) { } export default typedMemo(CellRendererComponent); -const styles = StyleSheet.create({ - zeroTranslate: { - transform: [ - { - translateX: 0, - }, - { - translateY: 0, - }, - ], - }, -}); runOnUI(() => { "worklet"; diff --git a/lib/module/components/CellRendererComponent.js.map b/lib/module/components/CellRendererComponent.js.map index a41dc61d..4d3ce8c7 100644 --- a/lib/module/components/CellRendererComponent.js.map +++ b/lib/module/components/CellRendererComponent.js.map @@ -1 +1 @@ -{"version":3,"names":["React","useEffect","useMemo","useRef","findNodeHandle","StyleSheet","Animated","runOnUI","useAnimatedStyle","useSharedValue","useDraggableFlatListContext","isWeb","useCellTranslate","typedMemo","useRefs","useAnimatedValues","CellProvider","useStableCallback","CellRendererComponent","props","item","index","onLayout","children","rest","viewRef","cellDataRef","propsRef","containerRef","horizontalAnim","scrollOffset","activeKey","keyExtractor","horizontal","layoutAnimationDisabled","key","offset","size","heldTanslate","translate","cellOffset","cellSize","cellIndex","isActive","animStyle","value","t","transform","translateX","translateY","updateCellMeasurements","onSuccess","x","y","w","h","current","set","measurements","onFail","debug","console","log","containerNode","viewNode","nodeHandle","measureLayout","onCellLayout","e","requestAnimationFrame","baseStyle","elevation","zIndex","flexDirection","itemEnteringAnimation","itemExitingAnimation","itemLayoutAnimation","enableLayoutAnimationExperimental","tag","_layoutDisabled","config","global","LayoutAnimationRepository","configs","stashConfig","stashedConfig","getStashedConfig","removeConfig","registerConfig","undefined","style","styles","zeroTranslate","create","RNDFLLayoutAnimationConfigStash"],"sources":["CellRendererComponent.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport {\n findNodeHandle,\n LayoutChangeEvent,\n MeasureLayoutOnSuccessCallback,\n StyleProp,\n StyleSheet,\n ViewStyle,\n} from \"react-native\";\nimport Animated, {\n runOnUI,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { isWeb } from \"../constants\";\nimport { useCellTranslate } from \"../hooks/useCellTranslate\";\nimport { typedMemo } from \"../utils\";\nimport { useRefs } from \"../context/refContext\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport CellProvider from \"../context/cellContext\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\n\ntype Props = {\n item: T;\n index: number;\n children: React.ReactNode;\n onLayout?: (e: LayoutChangeEvent) => void;\n style?: StyleProp;\n};\n\nfunction CellRendererComponent(props: Props) {\n const { item, index, onLayout, children, ...rest } = props;\n\n const viewRef = useRef(null);\n const { cellDataRef, propsRef, containerRef } = useRefs();\n\n const { horizontalAnim, scrollOffset } = useAnimatedValues();\n const {\n activeKey,\n keyExtractor,\n horizontal,\n layoutAnimationDisabled,\n } = useDraggableFlatListContext();\n\n const key = keyExtractor(item, index);\n const offset = useSharedValue(-1);\n const size = useSharedValue(-1);\n const heldTanslate = useSharedValue(0);\n\n const translate = useCellTranslate({\n cellOffset: offset,\n cellSize: size,\n cellIndex: index,\n });\n\n const isActive = activeKey === key;\n\n const animStyle = useAnimatedStyle(() => {\n // When activeKey becomes null at the end of a drag and the list reorders,\n // the animated style may apply before the next paint, causing a flicker.\n // Solution is to hold over the last animated value until the next onLayout.\n // (Not required in web)\n if (translate.value && !isWeb) {\n heldTanslate.value = translate.value;\n }\n const t = activeKey ? translate.value : heldTanslate.value;\n return {\n transform: [horizontalAnim.value ? { translateX: t } : { translateY: t }],\n };\n }, [translate, activeKey]);\n\n const updateCellMeasurements = useStableCallback(() => {\n const onSuccess: MeasureLayoutOnSuccessCallback = (x, y, w, h) => {\n if (isWeb && horizontal) x += scrollOffset.value;\n const cellOffset = horizontal ? x : y;\n const cellSize = horizontal ? w : h;\n cellDataRef.current.set(key, {\n measurements: { size: cellSize, offset: cellOffset },\n });\n\n size.value = cellSize;\n offset.value = cellOffset;\n };\n\n const onFail = () => {\n if (propsRef.current?.debug) {\n console.log(`## on measure fail, index: ${index}`);\n }\n };\n\n const containerNode = containerRef.current;\n const viewNode = viewRef.current;\n const nodeHandle = containerNode;\n\n if (viewNode && nodeHandle) {\n //@ts-ignore\n viewNode.measureLayout(nodeHandle, onSuccess, onFail);\n }\n });\n\n const onCellLayout = useStableCallback((e?: LayoutChangeEvent) => {\n heldTanslate.value = 0;\n updateCellMeasurements();\n if (onLayout && e) onLayout(e);\n });\n\n useEffect(() => {\n if (isWeb) {\n // onLayout isn't called on web when the cell index changes, so we manually re-measure\n requestAnimationFrame(() => {\n onCellLayout();\n });\n }\n }, [index, onCellLayout]);\n\n const baseStyle = useMemo(() => {\n return {\n elevation: isActive ? 1 : 0,\n zIndex: isActive ? 999 : 0,\n flexDirection: horizontal ? (\"row\" as const) : (\"column\" as const),\n };\n }, [isActive, horizontal]);\n\n const {\n itemEnteringAnimation,\n itemExitingAnimation,\n itemLayoutAnimation,\n } = propsRef.current;\n\n useEffect(() => {\n // NOTE: Keep an eye on reanimated LayoutAnimation refactor:\n // https://github.com/software-mansion/react-native-reanimated/pull/3332/files\n // We might have to change the way we register/unregister LayouAnimations:\n // - get native module: https://github.com/software-mansion/react-native-reanimated/blob/cf59766460d05eb30357913455318d8a95909468/src/reanimated2/NativeReanimated/NativeReanimated.ts#L18\n // - register layout animation for tag: https://github.com/software-mansion/react-native-reanimated/blob/cf59766460d05eb30357913455318d8a95909468/src/reanimated2/NativeReanimated/NativeReanimated.ts#L99\n if (!propsRef.current.enableLayoutAnimationExperimental) return;\n const tag = findNodeHandle(viewRef.current);\n\n runOnUI((t: number | null, _layoutDisabled) => {\n \"worklet\";\n if (!t) return;\n const config = global.LayoutAnimationRepository.configs[t];\n if (config) stashConfig(t, config);\n const stashedConfig = getStashedConfig(t);\n if (_layoutDisabled) {\n global.LayoutAnimationRepository.removeConfig(t);\n } else if (stashedConfig) {\n global.LayoutAnimationRepository.registerConfig(t, stashedConfig);\n }\n })(tag, layoutAnimationDisabled);\n }, [layoutAnimationDisabled]);\n\n return (\n \n {children}\n \n );\n}\n\nexport default typedMemo(CellRendererComponent);\n\nconst styles = StyleSheet.create({\n zeroTranslate: {\n transform: [{ translateX: 0 }, { translateY: 0 }],\n },\n});\n\ndeclare global {\n namespace NodeJS {\n interface Global {\n RNDFLLayoutAnimationConfigStash: Record;\n }\n }\n}\n\nrunOnUI(() => {\n \"worklet\";\n global.RNDFLLayoutAnimationConfigStash = {};\n})();\n\nfunction stashConfig(tag: number, config: unknown) {\n \"worklet\";\n if (!global.RNDFLLayoutAnimationConfigStash)\n global.RNDFLLayoutAnimationConfigStash = {};\n global.RNDFLLayoutAnimationConfigStash[tag] = config;\n}\n\nfunction getStashedConfig(tag: number) {\n \"worklet\";\n if (!global.RNDFLLayoutAnimationConfigStash) return null;\n return global.RNDFLLayoutAnimationConfigStash[tag] as Record;\n}\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,OAA3B,EAAoCC,MAApC,QAAkD,OAAlD;AACA,SACEC,cADF,EAKEC,UALF,QAOO,cAPP;AAQA,OAAOC,QAAP,IACEC,OADF,EAEEC,gBAFF,EAGEC,cAHF,QAIO,yBAJP;AAKA,SAASC,2BAAT,QAA4C,qCAA5C;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,gBAAT,QAAiC,2BAAjC;AACA,SAASC,SAAT,QAA0B,UAA1B;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,iBAAT,QAAkC,iCAAlC;AACA,OAAOC,YAAP,MAAyB,wBAAzB;AACA,SAASC,iBAAT,QAAkC,4BAAlC;;AAUA,SAASC,qBAAT,CAAkCC,KAAlC,EAAmD;EACjD,MAAM;IAAEC,IAAF;IAAQC,KAAR;IAAeC,QAAf;IAAyBC,QAAzB;IAAmC,GAAGC;EAAtC,IAA+CL,KAArD;EAEA,MAAMM,OAAO,GAAGtB,MAAM,CAAgB,IAAhB,CAAtB;EACA,MAAM;IAAEuB,WAAF;IAAeC,QAAf;IAAyBC;EAAzB,IAA0Cd,OAAO,EAAvD;EAEA,MAAM;IAAEe,cAAF;IAAkBC;EAAlB,IAAmCf,iBAAiB,EAA1D;EACA,MAAM;IACJgB,SADI;IAEJC,YAFI;IAGJC,UAHI;IAIJC;EAJI,IAKFxB,2BAA2B,EAL/B;EAOA,MA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AC6B,OAAT,CAAiBqB,iCAAjB,GACID,mBADJ,GAEIa,SATR;IAWE,KAAK,EAAE,CACLtE,KAAK,CAACuE,KADD,EAELpB,SAFK,EAGLvC,SAAS,GAAGa,SAAH,GAAe+C,MAAM,CAACC,aAH1B,CAXT;IAgBE,aAAa,EAAE7D,SAAS,GAAG,MAAH,GAAY;EAhBtC,iBAkBE,oBAAC,YAAD;IAAc,QAAQ,EAAEY;EAAxB,GAAmCpB,QAAnC,CAlBF,CADF;AAsBD;;AAED,eAAeV,SAAS,CAACK,qBAAD,CAAxB;AAEA,MAAMyE,MAAM,GAAGtF,UAAU,CAACwF,MAAX,CAAkB;EAC/BD,aAAa,EAAE;IACb7C,SAAS,EAAE,CAAC;MAAEC,UAAU,EAAE;IAAd,CAAD,EAAoB;MAAEC,UAAU,EAAE;IAAd,CAApB;EADE;AADgB,CAAlB,CAAf;AAcA1C,OAAO,CAAC,MAAM;EACZ;;EACA0E,MAAM,CAACa,+BAAP,GAAyC,EAAzC;AACD,CAHM,CAAP;;AAKA,SAASV,WAAT,CAAqBN,GAArB,EAAkCE,MAAlC,EAAmD;EACjD;;EACA,IAAI,CAACC,MAAM,CAACa,+BAAZ,EACEb,MAAM,CAACa,+BAAP,GAAyC,EAAzC;EACFb,MAAM,CAACa,+BAAP,CAAuChB,GAAvC,IAA8CE,MAA9C;AACD;;AAED,SAASM,gBAAT,CAA0BR,GAA1B,EAAuC;EACrC;;EACA,IAAI,CAACG,MAAM,CAACa,+BAAZ,EAA6C,OAAO,IAAP;EAC7C,OAAOb,MAAM,CAACa,+BAAP,CAAuChB,GAAvC,CAAP;AACD"} \ No newline at end of file +{"version":3,"names":["React","useEffect","useMemo","useRef","findNodeHandle","Animated","runOnUI","useAnimatedStyle","useSharedValue","useDraggableFlatListContext","isWeb","useCellTranslate","typedMemo","useRefs","useAnimatedValues","CellProvider","useStableCallback","CellRendererComponent","props","item","index","onLayout","children","rest","viewRef","cellDataRef","propsRef","containerRef","horizontalAnim","scrollOffset","activeKey","keyExtractor","horizontal","layoutAnimationDisabled","key","offset","size","heldTanslate","translate","cellOffset","cellSize","cellIndex","isActive","animStyle","value","t","transform","translateX","translateY","updateCellMeasurements","onSuccess","x","y","w","h","current","set","measurements","onFail","debug","console","log","containerNode","viewNode","nodeHandle","measureLayout","onCellLayout","e","requestAnimationFrame","baseStyle","elevation","zIndex","flexDirection","itemEnteringAnimation","itemExitingAnimation","itemLayoutAnimation","enableLayoutAnimationExperimental","tag","_layoutDisabled","config","global","LayoutAnimationRepository","configs","stashConfig","stashedConfig","getStashedConfig","removeConfig","registerConfig","undefined","style","RNDFLLayoutAnimationConfigStash"],"sources":["CellRendererComponent.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport {\n findNodeHandle,\n LayoutChangeEvent,\n MeasureLayoutOnSuccessCallback,\n StyleProp,\n ViewStyle,\n} from \"react-native\";\nimport Animated, {\n runOnUI,\n useAnimatedStyle,\n useSharedValue,\n} from \"react-native-reanimated\";\nimport { useDraggableFlatListContext } from \"../context/draggableFlatListContext\";\nimport { isWeb } from \"../constants\";\nimport { useCellTranslate } from \"../hooks/useCellTranslate\";\nimport { typedMemo } from \"../utils\";\nimport { useRefs } from \"../context/refContext\";\nimport { useAnimatedValues } from \"../context/animatedValueContext\";\nimport CellProvider from \"../context/cellContext\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\n\ntype Props = {\n item: T;\n index: number;\n children: React.ReactNode;\n onLayout?: (e: LayoutChangeEvent) => void;\n style?: StyleProp;\n};\n\nfunction CellRendererComponent(props: Props) {\n const { item, index, onLayout, children, ...rest } = props;\n\n const viewRef = useRef(null);\n const { cellDataRef, propsRef, containerRef } = useRefs();\n\n const { horizontalAnim, scrollOffset } = useAnimatedValues();\n const {\n activeKey,\n keyExtractor,\n horizontal,\n layoutAnimationDisabled,\n } = useDraggableFlatListContext();\n\n const key = keyExtractor(item, index);\n const offset = useSharedValue(-1);\n const size = useSharedValue(-1);\n const heldTanslate = useSharedValue(0);\n\n const translate = useCellTranslate({\n cellOffset: offset,\n cellSize: size,\n cellIndex: index,\n });\n\n const isActive = activeKey === key;\n\n const animStyle = useAnimatedStyle(() => {\n // When activeKey becomes null at the end of a drag and the list reorders,\n // the animated style may apply before the next paint, causing a flicker.\n // Solution is to hold over the last animated value until the next onLayout.\n // (Not required in web)\n if (translate.value && !isWeb) {\n heldTanslate.value = translate.value;\n }\n const t = isWeb ? translate.value : heldTanslate.value;\n return {\n transform: [horizontalAnim.value ? { translateX: t } : { translateY: t }],\n };\n }, [translate, activeKey]);\n\n const updateCellMeasurements = useStableCallback(() => {\n const onSuccess: MeasureLayoutOnSuccessCallback = (x, y, w, h) => {\n if (isWeb && horizontal) x += scrollOffset.value;\n const cellOffset = horizontal ? x : y;\n const cellSize = horizontal ? w : h;\n cellDataRef.current.set(key, {\n measurements: { size: cellSize, offset: cellOffset },\n });\n\n size.value = cellSize;\n offset.value = cellOffset;\n };\n\n const onFail = () => {\n if (propsRef.current?.debug) {\n console.log(`## on measure fail, index: ${index}`);\n }\n };\n\n const containerNode = containerRef.current;\n const viewNode = viewRef.current;\n const nodeHandle = containerNode;\n\n if (viewNode && nodeHandle) {\n //@ts-ignore\n viewNode.measureLayout(nodeHandle, onSuccess, onFail);\n }\n });\n\n const onCellLayout = useStableCallback((e?: LayoutChangeEvent) => {\n updateCellMeasurements();\n if (onLayout && e) onLayout(e);\n });\n\n useEffect(() => {\n heldTanslate.value = 0;\n if (isWeb) {\n // onLayout isn't called on web when the cell index changes, so we manually re-measure\n requestAnimationFrame(() => {\n onCellLayout();\n });\n }\n }, [index, onCellLayout]);\n\n const baseStyle = useMemo(() => {\n return {\n elevation: isActive ? 1 : 0,\n zIndex: isActive ? 999 : 0,\n flexDirection: horizontal ? (\"row\" as const) : (\"column\" as const),\n };\n }, [isActive, horizontal]);\n\n const {\n itemEnteringAnimation,\n itemExitingAnimation,\n itemLayoutAnimation,\n } = propsRef.current;\n\n useEffect(() => {\n // NOTE: Keep an eye on reanimated LayoutAnimation refactor:\n // https://github.com/software-mansion/react-native-reanimated/pull/3332/files\n // We might have to change the way we register/unregister LayouAnimations:\n // - get native module: https://github.com/software-mansion/react-native-reanimated/blob/cf59766460d05eb30357913455318d8a95909468/src/reanimated2/NativeReanimated/NativeReanimated.ts#L18\n // - register layout animation for tag: https://github.com/software-mansion/react-native-reanimated/blob/cf59766460d05eb30357913455318d8a95909468/src/reanimated2/NativeReanimated/NativeReanimated.ts#L99\n if (!propsRef.current.enableLayoutAnimationExperimental) return;\n const tag = findNodeHandle(viewRef.current);\n\n runOnUI((t: number | null, _layoutDisabled) => {\n \"worklet\";\n if (!t) return;\n const config = global.LayoutAnimationRepository.configs[t];\n if (config) stashConfig(t, config);\n const stashedConfig = getStashedConfig(t);\n if (_layoutDisabled) {\n global.LayoutAnimationRepository.removeConfig(t);\n } else if (stashedConfig) {\n global.LayoutAnimationRepository.registerConfig(t, stashedConfig);\n }\n })(tag, layoutAnimationDisabled);\n }, [layoutAnimationDisabled]);\n\n return (\n \n {children}\n \n );\n}\n\nexport default typedMemo(CellRendererComponent);\n\ndeclare global {\n namespace NodeJS {\n interface Global {\n RNDFLLayoutAnimationConfigStash: Record;\n }\n }\n}\n\nrunOnUI(() => {\n \"worklet\";\n global.RNDFLLayoutAnimationConfigStash = {};\n})();\n\nfunction stashConfig(tag: number, config: unknown) {\n \"worklet\";\n if (!global.RNDFLLayoutAnimationConfigStash)\n global.RNDFLLayoutAnimationConfigStash = {};\n global.RNDFLLayoutAnimationConfigStash[tag] = config;\n}\n\nfunction getStashedConfig(tag: number) {\n \"worklet\";\n if (!global.RNDFLLayoutAnimationConfigStash) return null;\n return global.RNDFLLayoutAnimationConfigStash[tag] as Record;\n}\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,OAA3B,EAAoCC,MAApC,QAAkD,OAAlD;AACA,SACEC,cADF,QAMO,cANP;AAOA,OAAOC,QAAP,IACEC,OADF,EAEEC,gBAFF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Z,EACEV,MAAM,CAACU,+BAAP,GAAyC,EAAzC;EACFV,MAAM,CAACU,+BAAP,CAAuCb,GAAvC,IAA8CE,MAA9C;AACD;;AAED,SAASM,gBAAT,CAA0BR,GAA1B,EAAuC;EACrC;;EACA,IAAI,CAACG,MAAM,CAACU,+BAAZ,EAA6C,OAAO,IAAP;EAC7C,OAAOV,MAAM,CAACU,+BAAP,CAAuCb,GAAvC,CAAP;AACD"} \ No newline at end of file diff --git a/package.json b/package.json index e4358219..5be2d6cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-draggable-flatlist", - "version": "4.0.1-mod.1", + "version": "4.0.1-mod.2", "description": "A drag-and-drop-enabled FlatList component for React Native", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/components/CellRendererComponent.tsx b/src/components/CellRendererComponent.tsx index d7b833b7..dedc5faa 100644 --- a/src/components/CellRendererComponent.tsx +++ b/src/components/CellRendererComponent.tsx @@ -4,7 +4,6 @@ import { LayoutChangeEvent, MeasureLayoutOnSuccessCallback, StyleProp, - StyleSheet, ViewStyle, } from "react-native"; import Animated, { @@ -64,7 +63,7 @@ function CellRendererComponent(props: Props) { if (translate.value && !isWeb) { heldTanslate.value = translate.value; } - const t = activeKey ? translate.value : heldTanslate.value; + const t = isWeb ? translate.value : heldTanslate.value; return { transform: [horizontalAnim.value ? { translateX: t } : { translateY: t }], }; @@ -100,12 +99,12 @@ function CellRendererComponent(props: Props) { }); const onCellLayout = useStableCallback((e?: LayoutChangeEvent) => { - heldTanslate.value = 0; updateCellMeasurements(); if (onLayout && e) onLayout(e); }); useEffect(() => { + heldTanslate.value = 0; if (isWeb) { // onLayout isn't called on web when the cell index changes, so we manually re-measure requestAnimationFrame(() => { @@ -163,11 +162,7 @@ function CellRendererComponent(props: Props) { ? itemLayoutAnimation : undefined } - style={[ - props.style, - baseStyle, - activeKey ? animStyle : styles.zeroTranslate, - ]} + style={[props.style, baseStyle, animStyle]} pointerEvents={activeKey ? "none" : "auto"} > {children} @@ -177,12 +172,6 @@ function CellRendererComponent(props: Props) { export default typedMemo(CellRendererComponent); -const styles = StyleSheet.create({ - zeroTranslate: { - transform: [{ translateX: 0 }, { translateY: 0 }], - }, -}); - declare global { namespace NodeJS { interface Global {