@teamturing/react-native-kit 1.2.3 → 1.2.4
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/lib/commonjs/component/Animation/implicit/OpacityAnimatedView.js +8 -5
- package/lib/commonjs/component/Animation/implicit/OpacityAnimatedView.js.map +1 -1
- package/lib/module/component/Animation/implicit/OpacityAnimatedView.js +9 -6
- package/lib/module/component/Animation/implicit/OpacityAnimatedView.js.map +1 -1
- package/package.json +2 -2
- package/src/component/Animation/implicit/OpacityAnimatedView.tsx +6 -6
|
@@ -17,10 +17,13 @@ const OpacityAnimatedView = ({
|
|
|
17
17
|
...rest
|
|
18
18
|
}) => {
|
|
19
19
|
const opacityValue = (0, _react.useRef)(new _reactNative.Animated.Value(opacity)).current;
|
|
20
|
-
const
|
|
20
|
+
const {
|
|
21
|
+
clearAllTimers,
|
|
22
|
+
setAutoClearTimeout
|
|
23
|
+
} = (0, _index.useTimeoutHandlers)();
|
|
21
24
|
const [dropChildren, setDropChildren] = (0, _react.useState)(!!(dropChildrenWhenInvisible && opacity === 0));
|
|
22
25
|
(0, _react.useEffect)(() => {
|
|
23
|
-
|
|
26
|
+
clearAllTimers();
|
|
24
27
|
const anim = _reactNative.Animated.timing(opacityValue, {
|
|
25
28
|
useNativeDriver: true,
|
|
26
29
|
toValue: opacity,
|
|
@@ -28,15 +31,15 @@ const OpacityAnimatedView = ({
|
|
|
28
31
|
});
|
|
29
32
|
anim.start();
|
|
30
33
|
if (opacity <= 0 && dropChildrenWhenInvisible) {
|
|
31
|
-
|
|
34
|
+
setAutoClearTimeout(() => setDropChildren(true), duration);
|
|
32
35
|
} else {
|
|
33
36
|
setDropChildren(false);
|
|
34
37
|
}
|
|
35
38
|
return () => {
|
|
36
|
-
|
|
39
|
+
clearAllTimers();
|
|
37
40
|
anim.stop();
|
|
38
41
|
};
|
|
39
|
-
}, [opacity, duration, opacityValue, dropChildrenWhenInvisible,
|
|
42
|
+
}, [opacity, duration, opacityValue, dropChildrenWhenInvisible, clearAllTimers, setAutoClearTimeout]);
|
|
40
43
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
41
44
|
style: [style, {
|
|
42
45
|
opacity: opacityValue
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_index","_jsxRuntime","OpacityAnimatedView","opacity","duration","style","dropChildrenWhenInvisible","children","rest","opacityValue","useRef","Animated","Value","current","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_index","_jsxRuntime","OpacityAnimatedView","opacity","duration","style","dropChildrenWhenInvisible","children","rest","opacityValue","useRef","Animated","Value","current","clearAllTimers","setAutoClearTimeout","useTimeoutHandlers","dropChildren","setDropChildren","useState","useEffect","anim","timing","useNativeDriver","toValue","start","stop","jsx","View","exports"],"sourceRoot":"../../../../../src","sources":["component/Animation/implicit/OpacityAnimatedView.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAAmD,IAAAG,WAAA,GAAAH,OAAA;AAGnD,MAAMI,mBAAmB,GAAGA,CAAC;EAC3BC,OAAO;EACPC,QAAQ,GAAG,GAAG;EACdC,KAAK;EACLC,yBAAyB,GAAG,KAAK;EACjCC,QAAQ;EACR,GAAGC;AACqB,CAAC,KAAK;EAC9B,MAAMC,YAAY,GAAG,IAAAC,aAAM,EAAC,IAAIC,qBAAQ,CAACC,KAAK,CAACT,OAAO,CAAC,CAAC,CAACU,OAAO;EAChE,MAAM;IAAEC,cAAc;IAAEC;EAAoB,CAAC,GAAG,IAAAC,yBAAkB,EAAC,CAAC;EACpE,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAG,IAAAC,eAAQ,EAAC,CAAC,EAAEb,yBAAyB,IAAIH,OAAO,KAAK,CAAC,CAAC,CAAC;EAChG,IAAAiB,gBAAS,EAAC,MAAM;IACdN,cAAc,CAAC,CAAC;IAChB,MAAMO,IAAI,GAAGV,qBAAQ,CAACW,MAAM,CAACb,YAAY,EAAE;MAAEc,eAAe,EAAE,IAAI;MAAEC,OAAO,EAAErB,OAAO;MAAEC;IAAS,CAAC,CAAC;IACjGiB,IAAI,CAACI,KAAK,CAAC,CAAC;IACZ,IAAItB,OAAO,IAAI,CAAC,IAAIG,yBAAyB,EAAE;MAC7CS,mBAAmB,CAAC,MAAMG,eAAe,CAAC,IAAI,CAAC,EAAEd,QAAQ,CAAC;IAC5D,CAAC,MAAM;MACLc,eAAe,CAAC,KAAK,CAAC;IACxB;IACA,OAAO,MAAM;MACXJ,cAAc,CAAC,CAAC;MAChBO,IAAI,CAACK,IAAI,CAAC,CAAC;IACb,CAAC;EACH,CAAC,EAAE,CAACvB,OAAO,EAAEC,QAAQ,EAAEK,YAAY,EAAEH,yBAAyB,EAAEQ,cAAc,EAAEC,mBAAmB,CAAC,CAAC;EAErG,oBACE,IAAAd,WAAA,CAAA0B,GAAA,EAAC5B,YAAA,CAAAY,QAAQ,CAACiB,IAAI;IAACvB,KAAK,EAAE,CAACA,KAAK,EAAE;MAAEF,OAAO,EAAEM;IAAa,CAAC,CAAE;IAAA,GAAKD,IAAI;IAAAD,QAAA,EAC/DU,YAAY,GAAG,IAAI,GAAGV;EAAQ,CAClB,CAAC;AAEpB,CAAC;AAACsB,OAAA,CAAA3B,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useRef, useEffect, useState } from 'react';
|
|
4
4
|
import { Animated } from 'react-native';
|
|
5
|
-
import {
|
|
5
|
+
import { useTimeoutHandlers } from "../../../hook/index.js";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
const OpacityAnimatedView = ({
|
|
8
8
|
opacity,
|
|
@@ -13,10 +13,13 @@ const OpacityAnimatedView = ({
|
|
|
13
13
|
...rest
|
|
14
14
|
}) => {
|
|
15
15
|
const opacityValue = useRef(new Animated.Value(opacity)).current;
|
|
16
|
-
const
|
|
16
|
+
const {
|
|
17
|
+
clearAllTimers,
|
|
18
|
+
setAutoClearTimeout
|
|
19
|
+
} = useTimeoutHandlers();
|
|
17
20
|
const [dropChildren, setDropChildren] = useState(!!(dropChildrenWhenInvisible && opacity === 0));
|
|
18
21
|
useEffect(() => {
|
|
19
|
-
|
|
22
|
+
clearAllTimers();
|
|
20
23
|
const anim = Animated.timing(opacityValue, {
|
|
21
24
|
useNativeDriver: true,
|
|
22
25
|
toValue: opacity,
|
|
@@ -24,15 +27,15 @@ const OpacityAnimatedView = ({
|
|
|
24
27
|
});
|
|
25
28
|
anim.start();
|
|
26
29
|
if (opacity <= 0 && dropChildrenWhenInvisible) {
|
|
27
|
-
|
|
30
|
+
setAutoClearTimeout(() => setDropChildren(true), duration);
|
|
28
31
|
} else {
|
|
29
32
|
setDropChildren(false);
|
|
30
33
|
}
|
|
31
34
|
return () => {
|
|
32
|
-
|
|
35
|
+
clearAllTimers();
|
|
33
36
|
anim.stop();
|
|
34
37
|
};
|
|
35
|
-
}, [opacity, duration, opacityValue, dropChildrenWhenInvisible,
|
|
38
|
+
}, [opacity, duration, opacityValue, dropChildrenWhenInvisible, clearAllTimers, setAutoClearTimeout]);
|
|
36
39
|
return /*#__PURE__*/_jsx(Animated.View, {
|
|
37
40
|
style: [style, {
|
|
38
41
|
opacity: opacityValue
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useEffect","useState","Animated","
|
|
1
|
+
{"version":3,"names":["useRef","useEffect","useState","Animated","useTimeoutHandlers","jsx","_jsx","OpacityAnimatedView","opacity","duration","style","dropChildrenWhenInvisible","children","rest","opacityValue","Value","current","clearAllTimers","setAutoClearTimeout","dropChildren","setDropChildren","anim","timing","useNativeDriver","toValue","start","stop","View"],"sourceRoot":"../../../../../src","sources":["component/Animation/implicit/OpacityAnimatedView.tsx"],"mappings":";;AACA,SAASA,M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ACEZ,IAAA,CAACH,QAAQ,CAACwB,IAAI;IAACjB,KAAK,EAAE,CAACA,KAAK,EAAE;MAAEF,OAAO,EAAEM;IAAa,CAAC,CAAE;IAAA,GAAKD,IAAI;IAAAD,QAAA,EAC/DO,YAAY,GAAG,IAAI,GAAGP;EAAQ,CAClB,CAAC;AAEpB,CAAC;AAED,SAASL,mBAAmB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamturing/react-native-kit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "React Native Common Module for Team Turing",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"example": "yarn workspace @teamturing/react-native-kit-example",
|
|
@@ -156,5 +156,5 @@
|
|
|
156
156
|
"bugs": {
|
|
157
157
|
"url": "https://github.com/weareteamturing/bombe/issues"
|
|
158
158
|
},
|
|
159
|
-
"gitHead": "
|
|
159
|
+
"gitHead": "d9d6fa7332fbef4df49698bc7ea4caab9b157b04"
|
|
160
160
|
}
|
|
@@ -3,7 +3,7 @@ import { useRef, useEffect, useState } from 'react';
|
|
|
3
3
|
import type { ViewProps } from 'react-native';
|
|
4
4
|
import { Animated } from 'react-native';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { useTimeoutHandlers } from '../../../hook';
|
|
7
7
|
|
|
8
8
|
type Props = { opacity: number; duration?: number; dropChildrenWhenInvisible?: boolean } & ViewProps;
|
|
9
9
|
const OpacityAnimatedView = ({
|
|
@@ -15,22 +15,22 @@ const OpacityAnimatedView = ({
|
|
|
15
15
|
...rest
|
|
16
16
|
}: PropsWithChildren<Props>) => {
|
|
17
17
|
const opacityValue = useRef(new Animated.Value(opacity)).current;
|
|
18
|
-
const
|
|
18
|
+
const { clearAllTimers, setAutoClearTimeout } = useTimeoutHandlers();
|
|
19
19
|
const [dropChildren, setDropChildren] = useState(!!(dropChildrenWhenInvisible && opacity === 0));
|
|
20
20
|
useEffect(() => {
|
|
21
|
-
|
|
21
|
+
clearAllTimers();
|
|
22
22
|
const anim = Animated.timing(opacityValue, { useNativeDriver: true, toValue: opacity, duration });
|
|
23
23
|
anim.start();
|
|
24
24
|
if (opacity <= 0 && dropChildrenWhenInvisible) {
|
|
25
|
-
|
|
25
|
+
setAutoClearTimeout(() => setDropChildren(true), duration);
|
|
26
26
|
} else {
|
|
27
27
|
setDropChildren(false);
|
|
28
28
|
}
|
|
29
29
|
return () => {
|
|
30
|
-
|
|
30
|
+
clearAllTimers();
|
|
31
31
|
anim.stop();
|
|
32
32
|
};
|
|
33
|
-
}, [opacity, duration, opacityValue, dropChildrenWhenInvisible,
|
|
33
|
+
}, [opacity, duration, opacityValue, dropChildrenWhenInvisible, clearAllTimers, setAutoClearTimeout]);
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
36
|
<Animated.View style={[style, { opacity: opacityValue }]} {...rest}>
|