@coinbase/cds-mobile 8.44.2 → 8.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dts/overlays/drawer/Drawer.d.ts +12 -0
- package/dts/overlays/drawer/Drawer.d.ts.map +1 -1
- package/dts/overlays/drawer/useDrawerAnimation.d.ts +29 -12
- package/dts/overlays/drawer/useDrawerAnimation.d.ts.map +1 -1
- package/dts/overlays/drawer/useDrawerPanResponder.d.ts +2 -2
- package/esm/overlays/__stories__/DrawerReduceMotion.stories.js +16 -0
- package/esm/overlays/__stories__/Drawers.js +3 -1
- package/esm/overlays/__stories__/TrayReduceMotion.stories.js +45 -0
- package/esm/overlays/drawer/Drawer.js +5 -3
- package/esm/overlays/drawer/useDrawerAnimation.js +40 -7
- package/esm/overlays/drawer/useDrawerPanResponder.js +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
|
|
9
9
|
<!-- template-start -->
|
|
10
10
|
|
|
11
|
+
## 8.45.0 (2/12/2026 PST)
|
|
12
|
+
|
|
13
|
+
#### 🚀 Updates
|
|
14
|
+
|
|
15
|
+
- Add reduce motion support for Tray. [[#386](https://github.com/coinbase/cds/pull/386)]
|
|
16
|
+
|
|
11
17
|
## 8.44.2 (2/10/2026 PST)
|
|
12
18
|
|
|
13
19
|
#### 🐞 Fixes
|
|
@@ -65,6 +65,12 @@ export type DrawerBaseProps = SharedProps &
|
|
|
65
65
|
* @deprecated Use TrayStickyFooter as a Tray child instead.
|
|
66
66
|
*/
|
|
67
67
|
stickyFooter?: DrawerRenderChildren | React.ReactNode;
|
|
68
|
+
/**
|
|
69
|
+
* When true, the drawer opens and closes with an opacity fade instead of
|
|
70
|
+
* a slide animation. Swipe-to-dismiss gestures remain enabled and use
|
|
71
|
+
* the slide transform so the drawer follows the user's finger naturally.
|
|
72
|
+
*/
|
|
73
|
+
reduceMotion?: boolean;
|
|
68
74
|
};
|
|
69
75
|
export type DrawerProps = DrawerBaseProps & {
|
|
70
76
|
styles?: {
|
|
@@ -136,6 +142,12 @@ export declare const Drawer: React.MemoExoticComponent<
|
|
|
136
142
|
* @deprecated Use TrayStickyFooter as a Tray child instead.
|
|
137
143
|
*/
|
|
138
144
|
stickyFooter?: DrawerRenderChildren | React.ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* When true, the drawer opens and closes with an opacity fade instead of
|
|
147
|
+
* a slide animation. Swipe-to-dismiss gestures remain enabled and use
|
|
148
|
+
* the slide transform so the drawer follows the user's finger naturally.
|
|
149
|
+
*/
|
|
150
|
+
reduceMotion?: boolean;
|
|
139
151
|
} & {
|
|
140
152
|
styles?: {
|
|
141
153
|
/** Root container element */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/overlays/drawer/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KASN,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAarF,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AASxE,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,EAAE,CAAC;IAAE,WAAW,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC,CAAC;AAEzE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gDAAgD;IAChD,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,WAAW,GACvC,IAAI,CAAC,wBAAwB,EAAE,oBAAoB,GAAG,yBAAyB,CAAC,GAChF,IAAI,CAAC,UAAU,EAAE,gBAAgB,G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
export declare const useDrawerAnimation: (
|
|
4
4
|
pin?: PinningDirection | undefined,
|
|
5
5
|
verticalDrawerPercentageOfView?: number | undefined,
|
|
6
|
+
reduceMotion?: boolean,
|
|
6
7
|
) => {
|
|
7
8
|
drawerAnimation: Animated.Value;
|
|
8
9
|
animateDrawerOut: Animated.CompositeAnimation;
|
|
9
10
|
animateDrawerIn: Animated.CompositeAnimation;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
animateSnapBack: Animated.CompositeAnimation;
|
|
12
|
+
drawerAnimationStyles:
|
|
13
|
+
| {
|
|
14
|
+
opacity: Animated.Value;
|
|
15
|
+
transform: (
|
|
16
|
+
| {
|
|
17
|
+
translateY: Animated.AnimatedInterpolation<string | number>;
|
|
18
|
+
translateX?: undefined;
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
translateX: Animated.AnimatedInterpolation<string | number>;
|
|
22
|
+
translateY?: undefined;
|
|
23
|
+
}
|
|
24
|
+
)[];
|
|
25
|
+
}
|
|
26
|
+
| {
|
|
27
|
+
transform: (
|
|
28
|
+
| {
|
|
29
|
+
translateY: Animated.AnimatedInterpolation<string | number>;
|
|
30
|
+
translateX?: undefined;
|
|
31
|
+
}
|
|
32
|
+
| {
|
|
33
|
+
translateX: Animated.AnimatedInterpolation<string | number>;
|
|
34
|
+
translateY?: undefined;
|
|
35
|
+
}
|
|
36
|
+
)[];
|
|
37
|
+
opacity?: undefined;
|
|
38
|
+
};
|
|
22
39
|
animateSwipeToClose: Animated.CompositeAnimation;
|
|
23
40
|
};
|
|
24
41
|
//# sourceMappingURL=useDrawerAnimation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrawerAnimation.d.ts","sourceRoot":"","sources":["../../../src/overlays/drawer/useDrawerAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAA+B,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAqB7E,eAAO,MAAM,kBAAkB,GAC7B,MAAK,gBAAgB,GAAG,SAAoB,EAC5C,iCAAgC,MAAM,GAAG,SAAiD
|
|
1
|
+
{"version":3,"file":"useDrawerAnimation.d.ts","sourceRoot":"","sources":["../../../src/overlays/drawer/useDrawerAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAA+B,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAkB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAqB7E,eAAO,MAAM,kBAAkB,GAC7B,MAAK,gBAAgB,GAAG,SAAoB,EAC5C,iCAAgC,MAAM,GAAG,SAAiD,EAC1F,eAAe,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;CAqHvB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import type { Animated } from 'react-native';
|
|
|
2
2
|
import type { PinningDirection } from '@coinbase/cds-common';
|
|
3
3
|
type UseDrawerPanResponderParams = {
|
|
4
4
|
drawerAnimation: Animated.Value;
|
|
5
|
-
|
|
5
|
+
animateSnapBack: Animated.CompositeAnimation;
|
|
6
6
|
pin: PinningDirection;
|
|
7
7
|
disableCapturePanGestureToDismiss: boolean;
|
|
8
8
|
onBlur?: () => void;
|
|
@@ -13,7 +13,7 @@ type UseDrawerPanResponderParams = {
|
|
|
13
13
|
export declare const useDrawerPanResponder: ({
|
|
14
14
|
pin,
|
|
15
15
|
drawerAnimation,
|
|
16
|
-
|
|
16
|
+
animateSnapBack,
|
|
17
17
|
disableCapturePanGestureToDismiss,
|
|
18
18
|
onBlur,
|
|
19
19
|
handleSwipeToClose,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Example, ExampleScreen } from '../../examples/ExampleScreen';
|
|
3
|
+
import { DefaultDrawer } from './Drawers';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
const DrawerReduceMotionScreen = () => {
|
|
6
|
+
return /*#__PURE__*/_jsx(ExampleScreen, {
|
|
7
|
+
children: /*#__PURE__*/_jsx(Example, {
|
|
8
|
+
title: "Reduce Motion Drawer",
|
|
9
|
+
children: /*#__PURE__*/_jsx(DefaultDrawer, {
|
|
10
|
+
reduceMotion: true,
|
|
11
|
+
pin: "bottom"
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export default DrawerReduceMotionScreen;
|
|
@@ -10,7 +10,8 @@ import { Drawer } from '../drawer/Drawer';
|
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
export const DefaultDrawer = _ref => {
|
|
12
12
|
let {
|
|
13
|
-
pin = 'left'
|
|
13
|
+
pin = 'left',
|
|
14
|
+
reduceMotion
|
|
14
15
|
} = _ref;
|
|
15
16
|
const [isVisible, setIsVisible] = useState(true);
|
|
16
17
|
const setIsVisibleOff = useCallback(() => setIsVisible(false), [setIsVisible]);
|
|
@@ -22,6 +23,7 @@ export const DefaultDrawer = _ref => {
|
|
|
22
23
|
}), isVisible && /*#__PURE__*/_jsx(Drawer, {
|
|
23
24
|
onCloseComplete: setIsVisibleOff,
|
|
24
25
|
pin: pin,
|
|
26
|
+
reduceMotion: reduceMotion,
|
|
25
27
|
children: _ref2 => {
|
|
26
28
|
let {
|
|
27
29
|
handleClose
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { Button } from '../../buttons/Button';
|
|
3
|
+
import { Example, ExampleScreen } from '../../examples/ExampleScreen';
|
|
4
|
+
import { VStack } from '../../layout';
|
|
5
|
+
import { Text } from '../../typography/Text';
|
|
6
|
+
import { Tray } from '../tray/Tray';
|
|
7
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
export const TrayReduceMotionScreen = () => {
|
|
9
|
+
return /*#__PURE__*/_jsx(ExampleScreen, {
|
|
10
|
+
children: /*#__PURE__*/_jsx(Example, {
|
|
11
|
+
title: "Reduce Motion Tray",
|
|
12
|
+
children: /*#__PURE__*/_jsx(TrayWithReduceMotion, {})
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
const TrayWithReduceMotion = () => {
|
|
17
|
+
const [isTrayVisible, setIsTrayVisible] = useState(false);
|
|
18
|
+
const setIsTrayVisibleOff = useCallback(() => setIsTrayVisible(false), [setIsTrayVisible]);
|
|
19
|
+
const setIsTrayVisibleOn = useCallback(() => setIsTrayVisible(true), [setIsTrayVisible]);
|
|
20
|
+
const trayRef = useRef(null);
|
|
21
|
+
const handleTrayVisibilityChange = useCallback(e => {
|
|
22
|
+
console.log('Tray visibility changed:', e);
|
|
23
|
+
}, []);
|
|
24
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
25
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
26
|
+
onPress: setIsTrayVisibleOn,
|
|
27
|
+
children: "Open"
|
|
28
|
+
}), isTrayVisible && /*#__PURE__*/_jsx(Tray, {
|
|
29
|
+
ref: trayRef,
|
|
30
|
+
reduceMotion: true,
|
|
31
|
+
handleBarVariant: "inside",
|
|
32
|
+
onCloseComplete: setIsTrayVisibleOff,
|
|
33
|
+
onVisibilityChange: handleTrayVisibilityChange,
|
|
34
|
+
title: "Header",
|
|
35
|
+
children: /*#__PURE__*/_jsx(VStack, {
|
|
36
|
+
paddingX: 3,
|
|
37
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
38
|
+
font: "body",
|
|
39
|
+
children: "Curabitur commodo nulla vel dolor vulputate vestibulum. Nulla et nisl molestie, interdum lorem id, viverra."
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
})]
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
export default TrayReduceMotionScreen;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["children", "pin", "onCloseComplete", "preventDismissGestures", "preventHardwareBackBehaviorAndroid", "handleBarVariant", "hideHandleBar", "disableCapturePanGestureToDismiss", "onBlur", "verticalDrawerPercentageOfView", "handleBarAccessibilityLabel", "accessibilityLabel", "accessibilityLabelledBy", "style", "styles", "accessibilityRole", "animationType"];
|
|
1
|
+
const _excluded = ["children", "pin", "onCloseComplete", "preventDismissGestures", "preventHardwareBackBehaviorAndroid", "handleBarVariant", "hideHandleBar", "disableCapturePanGestureToDismiss", "onBlur", "verticalDrawerPercentageOfView", "handleBarAccessibilityLabel", "accessibilityLabel", "accessibilityLabelledBy", "reduceMotion", "style", "styles", "accessibilityRole", "animationType"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
4
|
import React, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
@@ -38,6 +38,7 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
38
38
|
handleBarAccessibilityLabel = 'Dismiss',
|
|
39
39
|
accessibilityLabel,
|
|
40
40
|
accessibilityLabelledBy,
|
|
41
|
+
reduceMotion,
|
|
41
42
|
style,
|
|
42
43
|
styles,
|
|
43
44
|
accessibilityRole = 'alert',
|
|
@@ -54,9 +55,10 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
54
55
|
drawerAnimation,
|
|
55
56
|
animateDrawerOut,
|
|
56
57
|
animateDrawerIn,
|
|
58
|
+
animateSnapBack,
|
|
57
59
|
drawerAnimationStyles,
|
|
58
60
|
animateSwipeToClose
|
|
59
|
-
} = useDrawerAnimation(pin, verticalDrawerPercentageOfView);
|
|
61
|
+
} = useDrawerAnimation(pin, verticalDrawerPercentageOfView, reduceMotion);
|
|
60
62
|
const [opacityAnimation, animateOverlayIn, animateOverlayOut] = useOverlayAnimation(drawerAnimationDefaultDuration);
|
|
61
63
|
const paddingStyles = useDrawerSpacing(pin);
|
|
62
64
|
const isMounted = useRef(false);
|
|
@@ -100,7 +102,7 @@ export const Drawer = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Drawer(
|
|
|
100
102
|
const panGestureHandlers = useDrawerPanResponder({
|
|
101
103
|
pin,
|
|
102
104
|
drawerAnimation,
|
|
103
|
-
|
|
105
|
+
animateSnapBack,
|
|
104
106
|
disableCapturePanGestureToDismiss,
|
|
105
107
|
onBlur,
|
|
106
108
|
handleSwipeToClose,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1
2
|
import { useMemo, useRef } from 'react';
|
|
2
3
|
import { Animated, Easing, useWindowDimensions } from 'react-native';
|
|
3
4
|
import { animateDrawerInConfig, animateDrawerOutConfig, drawerAnimationDefaultDuration, MAX_OVER_DRAG } from '@coinbase/cds-common/animation/drawer';
|
|
@@ -8,7 +9,7 @@ const animateDrawer = {
|
|
|
8
9
|
animateIn: convertMotionConfig(animateDrawerInConfig),
|
|
9
10
|
animateOut: convertMotionConfig(animateDrawerOutConfig)
|
|
10
11
|
};
|
|
11
|
-
export const useDrawerAnimation = function (pin, verticalDrawerPercentageOfView) {
|
|
12
|
+
export const useDrawerAnimation = function (pin, verticalDrawerPercentageOfView, reduceMotion) {
|
|
12
13
|
if (pin === void 0) {
|
|
13
14
|
pin = 'bottom';
|
|
14
15
|
}
|
|
@@ -19,8 +20,30 @@ export const useDrawerAnimation = function (pin, verticalDrawerPercentageOfView)
|
|
|
19
20
|
const isPinVertical = pin === 'top' || pin === 'bottom';
|
|
20
21
|
const drawerDimension = isPinVertical ? windowDimensions.height * verticalDrawerPercentageOfView : windowDimensions.width * horizontalDrawerPercentageOfView;
|
|
21
22
|
const drawerAnimation = useRef(new Animated.Value(0));
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
// Separate opacity value used when reduceMotion is true so that
|
|
24
|
+
// open/close-button fades are independent of the transform that
|
|
25
|
+
// the pan-responder drives during swipe gestures.
|
|
26
|
+
const contentOpacity = useRef(new Animated.Value(reduceMotion ? 0 : 1));
|
|
27
|
+
const animateDrawerIn = useMemo(() => {
|
|
28
|
+
if (reduceMotion) {
|
|
29
|
+
return Animated.parallel([Animated.timing(drawerAnimation.current, _extends({}, animateDrawer.animateIn, {
|
|
30
|
+
duration: 0
|
|
31
|
+
})), Animated.timing(contentOpacity.current, animateDrawer.animateIn)]);
|
|
32
|
+
}
|
|
33
|
+
return Animated.timing(drawerAnimation.current, animateDrawer.animateIn);
|
|
34
|
+
}, [reduceMotion]);
|
|
35
|
+
const animateDrawerOut = useMemo(() => {
|
|
36
|
+
if (reduceMotion) {
|
|
37
|
+
return Animated.timing(contentOpacity.current, animateDrawer.animateOut);
|
|
38
|
+
}
|
|
39
|
+
return Animated.timing(drawerAnimation.current, animateDrawer.animateOut);
|
|
40
|
+
}, [reduceMotion]);
|
|
41
|
+
const animateSnapBack = useMemo(() => {
|
|
42
|
+
if (reduceMotion) {
|
|
43
|
+
return Animated.parallel([Animated.timing(drawerAnimation.current, animateDrawer.animateIn), Animated.timing(contentOpacity.current, animateDrawer.animateIn)]);
|
|
44
|
+
}
|
|
45
|
+
return Animated.timing(drawerAnimation.current, animateDrawer.animateIn);
|
|
46
|
+
}, [reduceMotion]);
|
|
24
47
|
|
|
25
48
|
/** custom animation config for swipe and fling to close that has no friction and is faster */
|
|
26
49
|
const animateSwipeToClose = useMemo(() => Animated.timing(drawerAnimation.current, {
|
|
@@ -62,15 +85,25 @@ export const useDrawerAnimation = function (pin, verticalDrawerPercentageOfView)
|
|
|
62
85
|
};
|
|
63
86
|
}
|
|
64
87
|
}, [pin, drawerDimension]);
|
|
88
|
+
const drawerAnimationStyles = useMemo(() => {
|
|
89
|
+
if (reduceMotion) {
|
|
90
|
+
return {
|
|
91
|
+
opacity: contentOpacity.current,
|
|
92
|
+
transform: [translation]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
transform: [translation]
|
|
97
|
+
};
|
|
98
|
+
}, [reduceMotion, translation]);
|
|
65
99
|
return useMemo(() => {
|
|
66
100
|
return {
|
|
67
101
|
drawerAnimation: drawerAnimation.current,
|
|
68
102
|
animateDrawerOut,
|
|
69
103
|
animateDrawerIn,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
},
|
|
104
|
+
animateSnapBack,
|
|
105
|
+
drawerAnimationStyles,
|
|
73
106
|
animateSwipeToClose
|
|
74
107
|
};
|
|
75
|
-
}, [animateDrawerOut, animateDrawerIn,
|
|
108
|
+
}, [animateDrawerOut, animateDrawerIn, animateSnapBack, drawerAnimationStyles, animateSwipeToClose]);
|
|
76
109
|
};
|
|
@@ -12,7 +12,7 @@ export const useDrawerPanResponder = _ref => {
|
|
|
12
12
|
let {
|
|
13
13
|
pin,
|
|
14
14
|
drawerAnimation,
|
|
15
|
-
|
|
15
|
+
animateSnapBack,
|
|
16
16
|
disableCapturePanGestureToDismiss,
|
|
17
17
|
onBlur,
|
|
18
18
|
handleSwipeToClose,
|
|
@@ -172,10 +172,10 @@ export const useDrawerPanResponder = _ref => {
|
|
|
172
172
|
onBlur == null || onBlur();
|
|
173
173
|
handleSwipeToClose();
|
|
174
174
|
} else {
|
|
175
|
-
|
|
175
|
+
animateSnapBack.start();
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
|
-
}, [drawerAnimation,
|
|
179
|
+
}, [drawerAnimation, animateSnapBack, parseGestureState, shouldCaptureGestures, shouldDismiss, drawerWidth, drawerHeight, pin, isHorizontalDrawer, onBlur, handleSwipeToClose, opacityAnimation]);
|
|
180
180
|
return panGestureHandlers;
|
|
181
181
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cds-mobile",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.45.0",
|
|
4
4
|
"description": "Coinbase Design System - Mobile",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"react-native-svg": "^14.1.0"
|
|
199
199
|
},
|
|
200
200
|
"dependencies": {
|
|
201
|
-
"@coinbase/cds-common": "^8.
|
|
201
|
+
"@coinbase/cds-common": "^8.45.0",
|
|
202
202
|
"@coinbase/cds-icons": "^5.11.0",
|
|
203
203
|
"@coinbase/cds-illustrations": "^4.31.0",
|
|
204
204
|
"@coinbase/cds-lottie-files": "^3.3.4",
|