@hero-design/rn 8.78.0-alpha.1 → 8.78.0-alpha.3
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/es/index.js +16 -14
- package/lib/index.js +16 -14
- package/package.json +2 -3
- package/src/components/BottomSheet/index.tsx +15 -16
package/es/index.js
CHANGED
|
@@ -9718,17 +9718,25 @@ var BottomSheet = function BottomSheet(_ref) {
|
|
|
9718
9718
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
9719
9719
|
internalShowDivider = _useState4[0],
|
|
9720
9720
|
setInternalShowDivider = _useState4[1];
|
|
9721
|
-
var canCallOnDismiss = useRef(false);
|
|
9722
9721
|
useEffect(function () {
|
|
9723
|
-
// Prevent calling onDismiss when the component has not yet opened
|
|
9724
|
-
if (open && !canCallOnDismiss.current) {
|
|
9725
|
-
canCallOnDismiss.current = true;
|
|
9726
|
-
}
|
|
9727
9722
|
// Show the modal before the open animation start
|
|
9728
9723
|
if (open && !visible) {
|
|
9729
9724
|
setVisibility(open);
|
|
9730
9725
|
}
|
|
9731
|
-
|
|
9726
|
+
// Delay closing the modal until after the closing animation end
|
|
9727
|
+
animatedValue.current.removeAllListeners();
|
|
9728
|
+
animatedValue.current.addListener(function (_ref2) {
|
|
9729
|
+
var value = _ref2.value;
|
|
9730
|
+
var endValueOfTransition = open ? 1 : 0;
|
|
9731
|
+
if (endValueOfTransition === 0 && value === endValueOfTransition) {
|
|
9732
|
+
setVisibility(false);
|
|
9733
|
+
onDismiss === null || onDismiss === void 0 || onDismiss();
|
|
9734
|
+
}
|
|
9735
|
+
});
|
|
9736
|
+
return function () {
|
|
9737
|
+
return animatedValue.current.removeAllListeners();
|
|
9738
|
+
};
|
|
9739
|
+
}, [open]);
|
|
9732
9740
|
// Animation
|
|
9733
9741
|
useEffect(function () {
|
|
9734
9742
|
var animation = Animated.timing(animatedValue.current, {
|
|
@@ -9736,17 +9744,11 @@ var BottomSheet = function BottomSheet(_ref) {
|
|
|
9736
9744
|
easing: Easing.inOut(Easing.cubic),
|
|
9737
9745
|
useNativeDriver: true
|
|
9738
9746
|
});
|
|
9739
|
-
animation.start(
|
|
9740
|
-
if (!open && canCallOnDismiss.current) {
|
|
9741
|
-
setVisibility(false);
|
|
9742
|
-
onDismiss === null || onDismiss === void 0 || onDismiss();
|
|
9743
|
-
}
|
|
9744
|
-
onAnimationEnd === null || onAnimationEnd === void 0 || onAnimationEnd();
|
|
9745
|
-
});
|
|
9747
|
+
animation.start(onAnimationEnd);
|
|
9746
9748
|
return function () {
|
|
9747
9749
|
return animation.stop();
|
|
9748
9750
|
};
|
|
9749
|
-
}, [open
|
|
9751
|
+
}, [open]);
|
|
9750
9752
|
var interpolateY = animatedValue.current.interpolate({
|
|
9751
9753
|
inputRange: [0, 1],
|
|
9752
9754
|
outputRange: [height, 0]
|
package/lib/index.js
CHANGED
|
@@ -9745,17 +9745,25 @@ var BottomSheet = function BottomSheet(_ref) {
|
|
|
9745
9745
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
9746
9746
|
internalShowDivider = _useState4[0],
|
|
9747
9747
|
setInternalShowDivider = _useState4[1];
|
|
9748
|
-
var canCallOnDismiss = React.useRef(false);
|
|
9749
9748
|
React.useEffect(function () {
|
|
9750
|
-
// Prevent calling onDismiss when the component has not yet opened
|
|
9751
|
-
if (open && !canCallOnDismiss.current) {
|
|
9752
|
-
canCallOnDismiss.current = true;
|
|
9753
|
-
}
|
|
9754
9749
|
// Show the modal before the open animation start
|
|
9755
9750
|
if (open && !visible) {
|
|
9756
9751
|
setVisibility(open);
|
|
9757
9752
|
}
|
|
9758
|
-
|
|
9753
|
+
// Delay closing the modal until after the closing animation end
|
|
9754
|
+
animatedValue.current.removeAllListeners();
|
|
9755
|
+
animatedValue.current.addListener(function (_ref2) {
|
|
9756
|
+
var value = _ref2.value;
|
|
9757
|
+
var endValueOfTransition = open ? 1 : 0;
|
|
9758
|
+
if (endValueOfTransition === 0 && value === endValueOfTransition) {
|
|
9759
|
+
setVisibility(false);
|
|
9760
|
+
onDismiss === null || onDismiss === void 0 || onDismiss();
|
|
9761
|
+
}
|
|
9762
|
+
});
|
|
9763
|
+
return function () {
|
|
9764
|
+
return animatedValue.current.removeAllListeners();
|
|
9765
|
+
};
|
|
9766
|
+
}, [open]);
|
|
9759
9767
|
// Animation
|
|
9760
9768
|
React.useEffect(function () {
|
|
9761
9769
|
var animation = reactNative.Animated.timing(animatedValue.current, {
|
|
@@ -9763,17 +9771,11 @@ var BottomSheet = function BottomSheet(_ref) {
|
|
|
9763
9771
|
easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
|
|
9764
9772
|
useNativeDriver: true
|
|
9765
9773
|
});
|
|
9766
|
-
animation.start(
|
|
9767
|
-
if (!open && canCallOnDismiss.current) {
|
|
9768
|
-
setVisibility(false);
|
|
9769
|
-
onDismiss === null || onDismiss === void 0 || onDismiss();
|
|
9770
|
-
}
|
|
9771
|
-
onAnimationEnd === null || onAnimationEnd === void 0 || onAnimationEnd();
|
|
9772
|
-
});
|
|
9774
|
+
animation.start(onAnimationEnd);
|
|
9773
9775
|
return function () {
|
|
9774
9776
|
return animation.stop();
|
|
9775
9777
|
};
|
|
9776
|
-
}, [open
|
|
9778
|
+
}, [open]);
|
|
9777
9779
|
var interpolateY = animatedValue.current.interpolate({
|
|
9778
9780
|
inputRange: [0, 1],
|
|
9779
9781
|
outputRange: [height, 0]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.78.0-alpha.
|
|
3
|
+
"version": "8.78.0-alpha.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -93,6 +93,5 @@
|
|
|
93
93
|
"ts-jest": "^29.1.1",
|
|
94
94
|
"typescript": "4.8.4"
|
|
95
95
|
},
|
|
96
|
-
"prettier": "prettier-config-hd"
|
|
97
|
-
"react-native": "src/index.ts"
|
|
96
|
+
"prettier": "prettier-config-hd"
|
|
98
97
|
}
|
|
@@ -115,19 +115,25 @@ const BottomSheet = ({
|
|
|
115
115
|
const animatedValue = useRef(new Animated.Value(open ? 0 : 1));
|
|
116
116
|
const [internalShowDivider, setInternalShowDivider] =
|
|
117
117
|
useState<boolean>(showDivider);
|
|
118
|
-
const canCallOnDismiss = useRef(false);
|
|
119
118
|
|
|
120
119
|
useEffect(() => {
|
|
121
|
-
// Prevent calling onDismiss when the component has not yet opened
|
|
122
|
-
if (open && !canCallOnDismiss.current) {
|
|
123
|
-
canCallOnDismiss.current = true;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
120
|
// Show the modal before the open animation start
|
|
127
121
|
if (open && !visible) {
|
|
128
122
|
setVisibility(open);
|
|
129
123
|
}
|
|
130
|
-
|
|
124
|
+
|
|
125
|
+
// Delay closing the modal until after the closing animation end
|
|
126
|
+
animatedValue.current.removeAllListeners();
|
|
127
|
+
animatedValue.current.addListener(({ value }) => {
|
|
128
|
+
const endValueOfTransition = open ? 1 : 0;
|
|
129
|
+
if (endValueOfTransition === 0 && value === endValueOfTransition) {
|
|
130
|
+
setVisibility(false);
|
|
131
|
+
onDismiss?.();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return () => animatedValue.current.removeAllListeners();
|
|
136
|
+
}, [open]);
|
|
131
137
|
|
|
132
138
|
// Animation
|
|
133
139
|
useEffect(() => {
|
|
@@ -137,17 +143,10 @@ const BottomSheet = ({
|
|
|
137
143
|
useNativeDriver: true,
|
|
138
144
|
});
|
|
139
145
|
|
|
140
|
-
animation.start(
|
|
141
|
-
if (!open && canCallOnDismiss.current) {
|
|
142
|
-
setVisibility(false);
|
|
143
|
-
onDismiss?.();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
onAnimationEnd?.();
|
|
147
|
-
});
|
|
146
|
+
animation.start(onAnimationEnd);
|
|
148
147
|
|
|
149
148
|
return () => animation.stop();
|
|
150
|
-
}, [open
|
|
149
|
+
}, [open]);
|
|
151
150
|
|
|
152
151
|
const interpolateY = animatedValue.current.interpolate({
|
|
153
152
|
inputRange: [0, 1],
|