@hero-design/rn 8.78.0-alpha.0 → 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 CHANGED
@@ -9718,16 +9718,24 @@ 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
  }
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
+ };
9731
9739
  }, [open]);
9732
9740
  // Animation
9733
9741
  useEffect(function () {
@@ -9736,15 +9744,7 @@ var BottomSheet = function BottomSheet(_ref) {
9736
9744
  easing: Easing.inOut(Easing.cubic),
9737
9745
  useNativeDriver: true
9738
9746
  });
9739
- animation.start(function () {
9740
- if (!open) {
9741
- setVisibility(false);
9742
- }
9743
- if (!open && canCallOnDismiss.current) {
9744
- onDismiss === null || onDismiss === void 0 || onDismiss();
9745
- }
9746
- onAnimationEnd === null || onAnimationEnd === void 0 || onAnimationEnd();
9747
- });
9747
+ animation.start(onAnimationEnd);
9748
9748
  return function () {
9749
9749
  return animation.stop();
9750
9750
  };
package/lib/index.js CHANGED
@@ -9745,16 +9745,24 @@ 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
  }
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
+ };
9758
9766
  }, [open]);
9759
9767
  // Animation
9760
9768
  React.useEffect(function () {
@@ -9763,15 +9771,7 @@ var BottomSheet = function BottomSheet(_ref) {
9763
9771
  easing: reactNative.Easing.inOut(reactNative.Easing.cubic),
9764
9772
  useNativeDriver: true
9765
9773
  });
9766
- animation.start(function () {
9767
- if (!open) {
9768
- setVisibility(false);
9769
- }
9770
- if (!open && canCallOnDismiss.current) {
9771
- onDismiss === null || onDismiss === void 0 || onDismiss();
9772
- }
9773
- onAnimationEnd === null || onAnimationEnd === void 0 || onAnimationEnd();
9774
- });
9774
+ animation.start(onAnimationEnd);
9775
9775
  return function () {
9776
9776
  return animation.stop();
9777
9777
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.78.0-alpha.0",
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,18 +115,24 @@ 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
  }
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();
130
136
  }, [open]);
131
137
 
132
138
  // Animation
@@ -137,17 +143,7 @@ const BottomSheet = ({
137
143
  useNativeDriver: true,
138
144
  });
139
145
 
140
- animation.start(() => {
141
- if (!open) {
142
- setVisibility(false);
143
- }
144
-
145
- if (!open && canCallOnDismiss.current) {
146
- onDismiss?.();
147
- }
148
-
149
- onAnimationEnd?.();
150
- });
146
+ animation.start(onAnimationEnd);
151
147
 
152
148
  return () => animation.stop();
153
149
  }, [open]);