You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
46 KiB
1 line
46 KiB
{"ast":null,"code":"import _defineProperty2 from \"@babel/runtime/helpers/defineProperty\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _assertThisInitialized from \"@babel/runtime/helpers/assertThisInitialized\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime/helpers/getPrototypeOf\";\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nimport * as React from 'react';\nimport { Component } from 'react';\nimport Animated from \"react-native-web/dist/exports/Animated\";\nimport StyleSheet from \"react-native-web/dist/exports/StyleSheet\";\nimport View from \"react-native-web/dist/exports/View\";\nimport I18nManager from \"react-native-web/dist/exports/I18nManager\";\nimport { PanGestureHandler } from \"../handlers/PanGestureHandler\";\nimport { TapGestureHandler } from \"../handlers/TapGestureHandler\";\nimport { State } from \"../State\";\nvar DRAG_TOSS = 0.05;\nvar Swipeable = function (_Component) {\n _inherits(Swipeable, _Component);\n var _super = _createSuper(Swipeable);\n function Swipeable(_props) {\n var _this;\n _classCallCheck(this, Swipeable);\n _this = _super.call(this, _props);\n _defineProperty(_assertThisInitialized(_this), \"onGestureEvent\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"transX\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"showLeftAction\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"leftActionTranslate\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"showRightAction\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"rightActionTranslate\", void 0);\n _defineProperty(_assertThisInitialized(_this), \"updateAnimatedEvent\", function (props, state) {\n var friction = props.friction,\n overshootFriction = props.overshootFriction;\n var dragX = state.dragX,\n rowTranslation = state.rowTranslation,\n _state$leftWidth = state.leftWidth,\n leftWidth = _state$leftWidth === void 0 ? 0 : _state$leftWidth,\n _state$rowWidth = state.rowWidth,\n rowWidth = _state$rowWidth === void 0 ? 0 : _state$rowWidth;\n var _state$rightOffset = state.rightOffset,\n rightOffset = _state$rightOffset === void 0 ? rowWidth : _state$rightOffset;\n var rightWidth = Math.max(0, rowWidth - rightOffset);\n var _props$overshootLeft = props.overshootLeft,\n overshootLeft = _props$overshootLeft === void 0 ? leftWidth > 0 : _props$overshootLeft,\n _props$overshootRight = props.overshootRight,\n overshootRight = _props$overshootRight === void 0 ? rightWidth > 0 : _props$overshootRight;\n var transX = Animated.add(rowTranslation, dragX.interpolate({\n inputRange: [0, friction],\n outputRange: [0, 1]\n })).interpolate({\n inputRange: [-rightWidth - 1, -rightWidth, leftWidth, leftWidth + 1],\n outputRange: [-rightWidth - (overshootRight ? 1 / overshootFriction : 0), -rightWidth, leftWidth, leftWidth + (overshootLeft ? 1 / overshootFriction : 0)]\n });\n _this.transX = transX;\n _this.showLeftAction = leftWidth > 0 ? transX.interpolate({\n inputRange: [-1, 0, leftWidth],\n outputRange: [0, 0, 1]\n }) : new Animated.Value(0);\n _this.leftActionTranslate = _this.showLeftAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp'\n });\n _this.showRightAction = rightWidth > 0 ? transX.interpolate({\n inputRange: [-rightWidth, 0, 1],\n outputRange: [1, 0, 0]\n }) : new Animated.Value(0);\n _this.rightActionTranslate = _this.showRightAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp'\n });\n });\n _defineProperty(_assertThisInitialized(_this), \"onTapHandlerStateChange\", function (_ref) {\n var nativeEvent = _ref.nativeEvent;\n if (nativeEvent.oldState === State.ACTIVE) {\n _this.close();\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"onHandlerStateChange\", function (ev) {\n if (ev.nativeEvent.oldState === State.ACTIVE) {\n _this.handleRelease(ev);\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"handleRelease\", function (ev) {\n var _ev$nativeEvent = ev.nativeEvent,\n velocityX = _ev$nativeEvent.velocityX,\n dragX = _ev$nativeEvent.translationX;\n var _this$state = _this.state,\n _this$state$leftWidth = _this$state.leftWidth,\n leftWidth = _this$state$leftWidth === void 0 ? 0 : _this$state$leftWidth,\n _this$state$rowWidth = _this$state.rowWidth,\n rowWidth = _this$state$rowWidth === void 0 ? 0 : _this$state$rowWidth,\n rowState = _this$state.rowState;\n var _this$state$rightOffs = _this.state.rightOffset,\n rightOffset = _this$state$rightOffs === void 0 ? rowWidth : _this$state$rightOffs;\n var rightWidth = rowWidth - rightOffset;\n var _this$props11 = _this.props,\n friction = _this$props11.friction,\n _this$props11$leftThr = _this$props11.leftThreshold,\n leftThreshold = _this$props11$leftThr === void 0 ? leftWidth / 2 : _this$props11$leftThr,\n _this$props11$rightTh = _this$props11.rightThreshold,\n rightThreshold = _this$props11$rightTh === void 0 ? rightWidth / 2 : _this$props11$rightTh;\n var startOffsetX = _this.currentOffset() + dragX / friction;\n var translationX = (dragX + DRAG_TOSS * velocityX) / friction;\n var toValue = 0;\n if (rowState === 0) {\n if (translationX > leftThreshold) {\n toValue = leftWidth;\n } else if (translationX < -rightThreshold) {\n toValue = -rightWidth;\n }\n } else if (rowState === 1) {\n if (translationX > -leftThreshold) {\n toValue = leftWidth;\n }\n } else {\n if (translationX < rightThreshold) {\n toValue = -rightWidth;\n }\n }\n _this.animateRow(startOffsetX, toValue, velocityX / friction);\n });\n _defineProperty(_assertThisInitialized(_this), \"animateRow\", function (fromValue, toValue, velocityX) {\n var _this$state2 = _this.state,\n dragX = _this$state2.dragX,\n rowTranslation = _this$state2.rowTranslation;\n dragX.setValue(0);\n rowTranslation.setValue(fromValue);\n _this.setState({\n rowState: Math.sign(toValue)\n });\n Animated.spring(rowTranslation, _objectSpread({\n restSpeedThreshold: 1.7,\n restDisplacementThreshold: 0.4,\n velocity: velocityX,\n bounciness: 0,\n toValue: toValue,\n useNativeDriver: _this.props.useNativeAnimations\n }, _this.props.animationOptions)).start(function (_ref2) {\n var finished = _ref2.finished;\n if (finished) {\n if (toValue > 0) {\n var _this$props$onSwipeab, _this$props, _this$props$onSwipeab2, _this$props2;\n (_this$props$onSwipeab = (_this$props = _this.props).onSwipeableLeftOpen) === null || _this$props$onSwipeab === void 0 ? void 0 : _this$props$onSwipeab.call(_this$props);\n (_this$props$onSwipeab2 = (_this$props2 = _this.props).onSwipeableOpen) === null || _this$props$onSwipeab2 === void 0 ? void 0 : _this$props$onSwipeab2.call(_this$props2, 'left', _assertThisInitialized(_this));\n } else if (toValue < 0) {\n var _this$props$onSwipeab3, _this$props3, _this$props$onSwipeab4, _this$props4;\n (_this$props$onSwipeab3 = (_this$props3 = _this.props).onSwipeableRightOpen) === null || _this$props$onSwipeab3 === void 0 ? void 0 : _this$props$onSwipeab3.call(_this$props3);\n (_this$props$onSwipeab4 = (_this$props4 = _this.props).onSwipeableOpen) === null || _this$props$onSwipeab4 === void 0 ? void 0 : _this$props$onSwipeab4.call(_this$props4, 'right', _assertThisInitialized(_this));\n } else {\n var _this$props$onSwipeab5, _this$props5;\n var closingDirection = fromValue > 0 ? 'left' : 'right';\n (_this$props$onSwipeab5 = (_this$props5 = _this.props).onSwipeableClose) === null || _this$props$onSwipeab5 === void 0 ? void 0 : _this$props$onSwipeab5.call(_this$props5, closingDirection, _assertThisInitialized(_this));\n }\n }\n });\n if (toValue > 0) {\n var _this$props$onSwipeab6, _this$props6, _this$props$onSwipeab7, _this$props7;\n (_this$props$onSwipeab6 = (_this$props6 = _this.props).onSwipeableLeftWillOpen) === null || _this$props$onSwipeab6 === void 0 ? void 0 : _this$props$onSwipeab6.call(_this$props6);\n (_this$props$onSwipeab7 = (_this$props7 = _this.props).onSwipeableWillOpen) === null || _this$props$onSwipeab7 === void 0 ? void 0 : _this$props$onSwipeab7.call(_this$props7, 'left');\n } else if (toValue < 0) {\n var _this$props$onSwipeab8, _this$props8, _this$props$onSwipeab9, _this$props9;\n (_this$props$onSwipeab8 = (_this$props8 = _this.props).onSwipeableRightWillOpen) === null || _this$props$onSwipeab8 === void 0 ? void 0 : _this$props$onSwipeab8.call(_this$props8);\n (_this$props$onSwipeab9 = (_this$props9 = _this.props).onSwipeableWillOpen) === null || _this$props$onSwipeab9 === void 0 ? void 0 : _this$props$onSwipeab9.call(_this$props9, 'right');\n } else {\n var _this$props$onSwipeab10, _this$props10;\n var closingDirection = fromValue > 0 ? 'left' : 'right';\n (_this$props$onSwipeab10 = (_this$props10 = _this.props).onSwipeableWillClose) === null || _this$props$onSwipeab10 === void 0 ? void 0 : _this$props$onSwipeab10.call(_this$props10, closingDirection);\n }\n });\n _defineProperty(_assertThisInitialized(_this), \"onRowLayout\", function (_ref3) {\n var nativeEvent = _ref3.nativeEvent;\n _this.setState({\n rowWidth: nativeEvent.layout.width\n });\n });\n _defineProperty(_assertThisInitialized(_this), \"currentOffset\", function () {\n var _this$state3 = _this.state,\n _this$state3$leftWidt = _this$state3.leftWidth,\n leftWidth = _this$state3$leftWidt === void 0 ? 0 : _this$state3$leftWidt,\n _this$state3$rowWidth = _this$state3.rowWidth,\n rowWidth = _this$state3$rowWidth === void 0 ? 0 : _this$state3$rowWidth,\n rowState = _this$state3.rowState;\n var _this$state$rightOffs2 = _this.state.rightOffset,\n rightOffset = _this$state$rightOffs2 === void 0 ? rowWidth : _this$state$rightOffs2;\n var rightWidth = rowWidth - rightOffset;\n if (rowState === 1) {\n return leftWidth;\n } else if (rowState === -1) {\n return -rightWidth;\n }\n return 0;\n });\n _defineProperty(_assertThisInitialized(_this), \"close\", function () {\n _this.animateRow(_this.currentOffset(), 0);\n });\n _defineProperty(_assertThisInitialized(_this), \"openLeft\", function () {\n var _this$state$leftWidth2 = _this.state.leftWidth,\n leftWidth = _this$state$leftWidth2 === void 0 ? 0 : _this$state$leftWidth2;\n _this.animateRow(_this.currentOffset(), leftWidth);\n });\n _defineProperty(_assertThisInitialized(_this), \"openRight\", function () {\n var _this$state$rowWidth2 = _this.state.rowWidth,\n rowWidth = _this$state$rowWidth2 === void 0 ? 0 : _this$state$rowWidth2;\n var _this$state$rightOffs3 = _this.state.rightOffset,\n rightOffset = _this$state$rightOffs3 === void 0 ? rowWidth : _this$state$rightOffs3;\n var rightWidth = rowWidth - rightOffset;\n _this.animateRow(_this.currentOffset(), -rightWidth);\n });\n var _dragX = new Animated.Value(0);\n _this.state = {\n dragX: _dragX,\n rowTranslation: new Animated.Value(0),\n rowState: 0,\n leftWidth: undefined,\n rightOffset: undefined,\n rowWidth: undefined\n };\n _this.updateAnimatedEvent(_props, _this.state);\n _this.onGestureEvent = Animated.event([{\n nativeEvent: {\n translationX: _dragX\n }\n }], {\n useNativeDriver: _props.useNativeAnimations\n });\n return _this;\n }\n _createClass(Swipeable, [{\n key: \"shouldComponentUpdate\",\n value: function shouldComponentUpdate(props, state) {\n if (this.props.friction !== props.friction || this.props.overshootLeft !== props.overshootLeft || this.props.overshootRight !== props.overshootRight || this.props.overshootFriction !== props.overshootFriction || this.state.leftWidth !== state.leftWidth || this.state.rightOffset !== state.rightOffset || this.state.rowWidth !== state.rowWidth) {\n this.updateAnimatedEvent(props, state);\n }\n return true;\n }\n }, {\n key: \"render\",\n value: function render() {\n var _this2 = this;\n var rowState = this.state.rowState;\n var _this$props12 = this.props,\n children = _this$props12.children,\n renderLeftActions = _this$props12.renderLeftActions,\n renderRightActions = _this$props12.renderRightActions;\n var left = renderLeftActions && React.createElement(Animated.View, {\n style: [styles.leftActions, {\n transform: [{\n translateX: this.leftActionTranslate\n }]\n }]\n }, renderLeftActions(this.showLeftAction, this.transX), React.createElement(View, {\n onLayout: function onLayout(_ref4) {\n var nativeEvent = _ref4.nativeEvent;\n return _this2.setState({\n leftWidth: nativeEvent.layout.x\n });\n }\n }));\n var right = renderRightActions && React.createElement(Animated.View, {\n style: [styles.rightActions, {\n transform: [{\n translateX: this.rightActionTranslate\n }]\n }]\n }, renderRightActions(this.showRightAction, this.transX, this), React.createElement(View, {\n onLayout: function onLayout(_ref5) {\n var nativeEvent = _ref5.nativeEvent;\n return _this2.setState({\n rightOffset: nativeEvent.layout.x\n });\n }\n }));\n return React.createElement(PanGestureHandler, _extends({\n activeOffsetX: [-10, 10]\n }, this.props, {\n onGestureEvent: this.onGestureEvent,\n onHandlerStateChange: this.onHandlerStateChange\n }), React.createElement(Animated.View, {\n onLayout: this.onRowLayout,\n style: [styles.container, this.props.containerStyle]\n }, left, right, React.createElement(TapGestureHandler, {\n enabled: rowState !== 0,\n onHandlerStateChange: this.onTapHandlerStateChange\n }, React.createElement(Animated.View, {\n pointerEvents: rowState === 0 ? 'auto' : 'box-only',\n style: [{\n transform: [{\n translateX: this.transX\n }]\n }, this.props.childrenContainerStyle]\n }, children))));\n }\n }]);\n return Swipeable;\n}(Component);\nexport { Swipeable as default };\n_defineProperty(Swipeable, \"defaultProps\", {\n friction: 1,\n overshootFriction: 1,\n useNativeAnimations: true\n});\nvar styles = StyleSheet.create({\n container: {\n overflow: 'hidden'\n },\n leftActions: _objectSpread(_objectSpread({}, StyleSheet.absoluteFillObject), {}, {\n flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row'\n }),\n rightActions: _objectSpread(_objectSpread({}, StyleSheet.absoluteFillObject), {}, {\n flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse'\n })\n});","map":{"version":3,"sources":["Swipeable.tsx"],"names":["React","Component","PanGestureHandler","TapGestureHandler","State","DRAG_TOSS","Swipeable","friction","overshootFriction","useNativeAnimations","constructor","props","dragX","Animated","Value","state","rowTranslation","rowState","leftWidth","undefined","rightOffset","rowWidth","updateAnimatedEvent","onGestureEvent","event","nativeEvent","translationX","useNativeDriver","shouldComponentUpdate","overshootLeft","overshootRight","rightWidth","Math","max","transX","add","interpolate","inputRange","outputRange","showLeftAction","leftActionTranslate","Number","MIN_VALUE","extrapolate","showRightAction","rightActionTranslate","oldState","ACTIVE","close","ev","handleRelease","velocityX","leftThreshold","rightThreshold","startOffsetX","currentOffset","toValue","animateRow","fromValue","setValue","setState","sign","spring","restSpeedThreshold","restDisplacementThreshold","velocity","bounciness","animationOptions","start","finished","onSwipeableLeftOpen","onSwipeableOpen","onSwipeableRightOpen","closingDirection","onSwipeableClose","onSwipeableLeftWillOpen","onSwipeableWillOpen","onSwipeableRightWillOpen","onSwipeableWillClose","layout","width","render","children","renderLeftActions","renderRightActions","left","styles","leftActions","transform","translateX","x","right","rightActions","onHandlerStateChange","onRowLayout","container","containerStyle","onTapHandlerStateChange","childrenContainerStyle","create","overflow","StyleSheet","absoluteFillObject","flexDirection","I18nManager","isRTL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,QAA0B,OAA1B;AAAA;AAAA;AAAA;AAAA;AAeA,SACEC,iBADF;AAKA,SACEC,iBADF;AAIA,SAASC,KAAT;AAEA,IAAMC,SAAS,GAAG,IAAlB;AAAA,IA0KqBC,SAAN;EAAA;EAAA;EAUbI,mBAAYC,MAAD,EAAwB;IAAA;IAAA;IACjC,0BAAMA,MAAN;IADiC,eAAA,gCAAA,gBAAA,EAAA,KAAA,CAAA,CAAA;IAAA,eAAA,gCAAA,QAAA,EAAA,KAAA,CAAA,CAAA;IAAA,eAAA,gCAAA,gBAAA,EAAA,KAAA,CAAA,CAAA;IAAA,eAAA,gCAAA,qBAAA,EAAA,KAAA,CAAA,CAAA;IAAA,eAAA,gCAAA,iBAAA,EAAA,KAAA,CAAA,CAAA;IAAA,eAAA,gCAAA,sBAAA,EAAA,KAAA,CAAA,CAAA;IAAA,eAAA,gCAAA,qBAAA,EA4CL,UAC5BA,KAD4B,EAE5BI,KAF4B,EAGzB;MACH,IAAQR,QAAF,GAAkCI,KAAxC,CAAQJ,QAAF;QAAYC,iBAAAA,GAAsBG,KAAxC,CAAkBH,iBAAAA;MAClB,IAAQI,KAAF,GAAyDG,KAA/D,CAAQH,KAAF;QAASI,cAAT,GAAyDD,KAA/D,CAAeC,cAAT;QAAA,mBAAyDD,KAA/D,CAA+BG,SAAS;QAATA,SAAS,iCAAG,CAArC;QAAA,kBAAyDH,KAA/D,CAA8CM,QAAQ;QAARA,Q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AlB,CAAf","sourcesContent":["// Similarily to the DrawerLayout component this deserves to be put in a\n// separate repo. Although, keeping it here for the time being will allow us to\n// move faster and fix possible issues quicker\n\nimport * as React from 'react';\nimport { Component } from 'react';\nimport {\n Animated,\n StyleSheet,\n View,\n I18nManager,\n LayoutChangeEvent,\n StyleProp,\n ViewStyle,\n} from 'react-native';\n\nimport {\n GestureEvent,\n HandlerStateChangeEvent,\n} from '../handlers/gestureHandlerCommon';\nimport {\n PanGestureHandler,\n PanGestureHandlerEventPayload,\n PanGestureHandlerProps,\n} from '../handlers/PanGestureHandler';\nimport {\n TapGestureHandler,\n TapGestureHandlerEventPayload,\n} from '../handlers/TapGestureHandler';\nimport { State } from '../State';\n\nconst DRAG_TOSS = 0.05;\n\ntype SwipeableExcludes = Exclude<\n keyof PanGestureHandlerProps,\n 'onGestureEvent' | 'onHandlerStateChange'\n>;\n\n// Animated.AnimatedInterpolation has been converted to a generic type\n// in @types/react-native 0.70. This way we can maintain compatibility\n// with all versions of @types/react-native\ntype AnimatedInterpolation = ReturnType<Animated.Value['interpolate']>;\n\nexport interface SwipeableProps\n extends Pick<PanGestureHandlerProps, SwipeableExcludes> {\n /**\n * Enables two-finger gestures on supported devices, for example iPads with\n * trackpads. If not enabled the gesture will require click + drag, with\n * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger\n * the gesture.\n */\n enableTrackpadTwoFingerGesture?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance. e.g. value of 1 will indicate that the swipeable panel\n * should exactly follow the gesture, 2 means it is going to be two times\n * \"slower\".\n */\n friction?: number;\n\n /**\n * Distance from the left edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n leftThreshold?: number;\n\n /**\n * Distance from the right edge at which released panel will animate to the\n * open state (or the open panel will animate into the closed state). By\n * default it's a half of the panel's width.\n */\n rightThreshold?: number;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the left\n * actions panel's width. It is set to true by default as long as the left\n * panel render method is present.\n */\n overshootLeft?: boolean;\n\n /**\n * Value indicating if the swipeable panel can be pulled further than the\n * right actions panel's width. It is set to true by default as long as the\n * right panel render method is present.\n */\n overshootRight?: boolean;\n\n /**\n * Specifies how much the visual interaction will be delayed compared to the\n * gesture distance at overshoot. Default value is 1, it mean no friction, for\n * a native feel, try 8 or above.\n */\n overshootFriction?: number;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableOpen()\n *\n * Called when left action panel gets open.\n */\n onSwipeableLeftOpen?: () => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableOpen()\n *\n * Called when right action panel gets open.\n */\n onSwipeableRightOpen?: () => void;\n\n /**\n * Called when action panel gets open (either right or left).\n */\n onSwipeableOpen?: (direction: 'left' | 'right', swipeable: Swipeable) => void;\n\n /**\n * Called when action panel is closed.\n */\n onSwipeableClose?: (\n direction: 'left' | 'right',\n swipeable: Swipeable\n ) => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableWillOpen()\n *\n * Called when left action panel starts animating on open.\n */\n onSwipeableLeftWillOpen?: () => void;\n\n /**\n * @deprecated Use `direction` argument of onSwipeableWillOpen()\n *\n * Called when right action panel starts animating on open.\n */\n onSwipeableRightWillOpen?: () => void;\n\n /**\n * Called when action panel starts animating on open (either right or left).\n */\n onSwipeableWillOpen?: (direction: 'left' | 'right') => void;\n\n /**\n * Called when action panel starts animating on close.\n */\n onSwipeableWillClose?: (direction: 'left' | 'right') => void;\n\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, +]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderLeftActions?: (\n progressAnimatedValue: AnimatedInterpolation,\n dragAnimatedValue: AnimatedInterpolation\n ) => React.ReactNode;\n /**\n *\n * This map describes the values to use as inputRange for extra interpolation:\n * AnimatedValue: [startValue, endValue]\n *\n * progressAnimatedValue: [0, 1] dragAnimatedValue: [0, -]\n *\n * To support `rtl` flexbox layouts use `flexDirection` styling.\n * */\n renderRightActions?: (\n progressAnimatedValue: AnimatedInterpolation,\n dragAnimatedValue: AnimatedInterpolation,\n swipeable: Swipeable\n ) => React.ReactNode;\n\n useNativeAnimations?: boolean;\n\n animationOptions?: Record<string, unknown>;\n\n /**\n * Style object for the container (`Animated.View`), for example to override\n * `overflow: 'hidden'`.\n */\n containerStyle?: StyleProp<ViewStyle>;\n\n /**\n * Style object for the children container (`Animated.View`), for example to\n * apply `flex: 1`\n */\n childrenContainerStyle?: StyleProp<ViewStyle>;\n}\n\ntype SwipeableState = {\n dragX: Animated.Value;\n rowTranslation: Animated.Value;\n rowState: number;\n leftWidth?: number;\n rightOffset?: number;\n rowWidth?: number;\n};\n\nexport default class Swipeable extends Component<\n SwipeableProps,\n SwipeableState\n> {\n static defaultProps = {\n friction: 1,\n overshootFriction: 1,\n useNativeAnimations: true,\n };\n\n constructor(props: SwipeableProps) {\n super(props);\n const dragX = new Animated.Value(0);\n this.state = {\n dragX,\n rowTranslation: new Animated.Value(0),\n rowState: 0,\n leftWidth: undefined,\n rightOffset: undefined,\n rowWidth: undefined,\n };\n this.updateAnimatedEvent(props, this.state);\n\n this.onGestureEvent = Animated.event(\n [{ nativeEvent: { translationX: dragX } }],\n { useNativeDriver: props.useNativeAnimations! }\n );\n }\n\n shouldComponentUpdate(props: SwipeableProps, state: SwipeableState) {\n if (\n this.props.friction !== props.friction ||\n this.props.overshootLeft !== props.overshootLeft ||\n this.props.overshootRight !== props.overshootRight ||\n this.props.overshootFriction !== props.overshootFriction ||\n this.state.leftWidth !== state.leftWidth ||\n this.state.rightOffset !== state.rightOffset ||\n this.state.rowWidth !== state.rowWidth\n ) {\n this.updateAnimatedEvent(props, state);\n }\n\n return true;\n }\n\n private onGestureEvent?: (\n event: GestureEvent<PanGestureHandlerEventPayload>\n ) => void;\n private transX?: AnimatedInterpolation;\n private showLeftAction?: AnimatedInterpolation | Animated.Value;\n private leftActionTranslate?: AnimatedInterpolation;\n private showRightAction?: AnimatedInterpolation | Animated.Value;\n private rightActionTranslate?: AnimatedInterpolation;\n\n private updateAnimatedEvent = (\n props: SwipeableProps,\n state: SwipeableState\n ) => {\n const { friction, overshootFriction } = props;\n const { dragX, rowTranslation, leftWidth = 0, rowWidth = 0 } = state;\n const { rightOffset = rowWidth } = state;\n const rightWidth = Math.max(0, rowWidth - rightOffset);\n\n const { overshootLeft = leftWidth > 0, overshootRight = rightWidth > 0 } =\n props;\n\n const transX = Animated.add(\n rowTranslation,\n dragX.interpolate({\n inputRange: [0, friction!],\n outputRange: [0, 1],\n })\n ).interpolate({\n inputRange: [-rightWidth - 1, -rightWidth, leftWidth, leftWidth + 1],\n outputRange: [\n -rightWidth - (overshootRight ? 1 / overshootFriction! : 0),\n -rightWidth,\n leftWidth,\n leftWidth + (overshootLeft ? 1 / overshootFriction! : 0),\n ],\n });\n this.transX = transX;\n this.showLeftAction =\n leftWidth > 0\n ? transX.interpolate({\n inputRange: [-1, 0, leftWidth],\n outputRange: [0, 0, 1],\n })\n : new Animated.Value(0);\n this.leftActionTranslate = this.showLeftAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp',\n });\n this.showRightAction =\n rightWidth > 0\n ? transX.interpolate({\n inputRange: [-rightWidth, 0, 1],\n outputRange: [1, 0, 0],\n })\n : new Animated.Value(0);\n this.rightActionTranslate = this.showRightAction.interpolate({\n inputRange: [0, Number.MIN_VALUE],\n outputRange: [-10000, 0],\n extrapolate: 'clamp',\n });\n };\n\n private onTapHandlerStateChange = ({\n nativeEvent,\n }: HandlerStateChangeEvent<TapGestureHandlerEventPayload>) => {\n if (nativeEvent.oldState === State.ACTIVE) {\n this.close();\n }\n };\n\n private onHandlerStateChange = (\n ev: HandlerStateChangeEvent<PanGestureHandlerEventPayload>\n ) => {\n if (ev.nativeEvent.oldState === State.ACTIVE) {\n this.handleRelease(ev);\n }\n };\n\n private handleRelease = (\n ev: HandlerStateChangeEvent<PanGestureHandlerEventPayload>\n ) => {\n const { velocityX, translationX: dragX } = ev.nativeEvent;\n const { leftWidth = 0, rowWidth = 0, rowState } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n const {\n friction,\n leftThreshold = leftWidth / 2,\n rightThreshold = rightWidth / 2,\n } = this.props;\n\n const startOffsetX = this.currentOffset() + dragX / friction!;\n const translationX = (dragX + DRAG_TOSS * velocityX) / friction!;\n\n let toValue = 0;\n if (rowState === 0) {\n if (translationX > leftThreshold) {\n toValue = leftWidth;\n } else if (translationX < -rightThreshold) {\n toValue = -rightWidth;\n }\n } else if (rowState === 1) {\n // swiped to left\n if (translationX > -leftThreshold) {\n toValue = leftWidth;\n }\n } else {\n // swiped to right\n if (translationX < rightThreshold) {\n toValue = -rightWidth;\n }\n }\n\n this.animateRow(startOffsetX, toValue, velocityX / friction!);\n };\n\n private animateRow = (\n fromValue: number,\n toValue: number,\n velocityX?:\n | number\n | {\n x: number;\n y: number;\n }\n ) => {\n const { dragX, rowTranslation } = this.state;\n dragX.setValue(0);\n rowTranslation.setValue(fromValue);\n\n this.setState({ rowState: Math.sign(toValue) });\n Animated.spring(rowTranslation, {\n restSpeedThreshold: 1.7,\n restDisplacementThreshold: 0.4,\n velocity: velocityX,\n bounciness: 0,\n toValue,\n useNativeDriver: this.props.useNativeAnimations!,\n ...this.props.animationOptions,\n }).start(({ finished }) => {\n if (finished) {\n if (toValue > 0) {\n this.props.onSwipeableLeftOpen?.();\n this.props.onSwipeableOpen?.('left', this);\n } else if (toValue < 0) {\n this.props.onSwipeableRightOpen?.();\n this.props.onSwipeableOpen?.('right', this);\n } else {\n const closingDirection = fromValue > 0 ? 'left' : 'right';\n this.props.onSwipeableClose?.(closingDirection, this);\n }\n }\n });\n if (toValue > 0) {\n this.props.onSwipeableLeftWillOpen?.();\n this.props.onSwipeableWillOpen?.('left');\n } else if (toValue < 0) {\n this.props.onSwipeableRightWillOpen?.();\n this.props.onSwipeableWillOpen?.('right');\n } else {\n const closingDirection = fromValue > 0 ? 'left' : 'right';\n this.props.onSwipeableWillClose?.(closingDirection);\n }\n };\n\n private onRowLayout = ({ nativeEvent }: LayoutChangeEvent) => {\n this.setState({ rowWidth: nativeEvent.layout.width });\n };\n\n private currentOffset = () => {\n const { leftWidth = 0, rowWidth = 0, rowState } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n if (rowState === 1) {\n return leftWidth;\n } else if (rowState === -1) {\n return -rightWidth;\n }\n return 0;\n };\n\n close = () => {\n this.animateRow(this.currentOffset(), 0);\n };\n\n openLeft = () => {\n const { leftWidth = 0 } = this.state;\n this.animateRow(this.currentOffset(), leftWidth);\n };\n\n openRight = () => {\n const { rowWidth = 0 } = this.state;\n const { rightOffset = rowWidth } = this.state;\n const rightWidth = rowWidth - rightOffset;\n this.animateRow(this.currentOffset(), -rightWidth);\n };\n\n render() {\n const { rowState } = this.state;\n const { children, renderLeftActions, renderRightActions } = this.props;\n\n const left = renderLeftActions && (\n <Animated.View\n style={[\n styles.leftActions,\n // all those and below parameters can have ! since they are all\n // asigned in constructor in `updateAnimatedEvent` but TS cannot spot\n // it for some reason\n { transform: [{ translateX: this.leftActionTranslate! }] },\n ]}>\n {renderLeftActions(this.showLeftAction!, this.transX!)}\n <View\n onLayout={({ nativeEvent }) =>\n this.setState({ leftWidth: nativeEvent.layout.x })\n }\n />\n </Animated.View>\n );\n\n const right = renderRightActions && (\n <Animated.View\n style={[\n styles.rightActions,\n { transform: [{ translateX: this.rightActionTranslate! }] },\n ]}>\n {renderRightActions(this.showRightAction!, this.transX!, this)}\n <View\n onLayout={({ nativeEvent }) =>\n this.setState({ rightOffset: nativeEvent.layout.x })\n }\n />\n </Animated.View>\n );\n\n return (\n <PanGestureHandler\n activeOffsetX={[-10, 10]}\n {...this.props}\n onGestureEvent={this.onGestureEvent}\n onHandlerStateChange={this.onHandlerStateChange}>\n <Animated.View\n onLayout={this.onRowLayout}\n style={[styles.container, this.props.containerStyle]}>\n {left}\n {right}\n <TapGestureHandler\n enabled={rowState !== 0}\n onHandlerStateChange={this.onTapHandlerStateChange}>\n <Animated.View\n pointerEvents={rowState === 0 ? 'auto' : 'box-only'}\n style={[\n {\n transform: [{ translateX: this.transX! }],\n },\n this.props.childrenContainerStyle,\n ]}>\n {children}\n </Animated.View>\n </TapGestureHandler>\n </Animated.View>\n </PanGestureHandler>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n leftActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',\n },\n rightActions: {\n ...StyleSheet.absoluteFillObject,\n flexDirection: I18nManager.isRTL ? 'row' : 'row-reverse',\n },\n});\n"]},"metadata":{},"sourceType":"module"} |