@fountain-ui/lab 1.16.1 → 1.18.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 +24 -0
- package/build/commonjs/Carousel/CarouselNative.js +3 -3
- package/build/commonjs/Carousel/CarouselNative.js.map +1 -1
- package/build/commonjs/FlipCard/FlipCard.js +83 -0
- package/build/commonjs/FlipCard/FlipCard.js.map +1 -0
- package/build/commonjs/FlipCard/FlipCardProps.js +2 -0
- package/build/commonjs/FlipCard/FlipCardProps.js.map +1 -0
- package/build/commonjs/FlipCard/index.js +16 -0
- package/build/commonjs/FlipCard/index.js.map +1 -0
- package/build/commonjs/index.js +21 -0
- package/build/commonjs/index.js.map +1 -1
- package/build/module/Carousel/CarouselNative.js +2 -2
- package/build/module/Carousel/CarouselNative.js.map +1 -1
- package/build/module/FlipCard/FlipCard.js +60 -0
- package/build/module/FlipCard/FlipCard.js.map +1 -0
- package/build/module/FlipCard/FlipCardProps.js +2 -0
- package/build/module/FlipCard/FlipCardProps.js.map +1 -0
- package/build/module/FlipCard/index.js +2 -0
- package/build/module/FlipCard/index.js.map +1 -0
- package/build/module/index.js +2 -0
- package/build/module/index.js.map +1 -1
- package/build/typescript/FlipCard/FlipCard.d.ts +3 -0
- package/build/typescript/FlipCard/FlipCardProps.d.ts +17 -0
- package/build/typescript/FlipCard/index.d.ts +2 -0
- package/build/typescript/index.d.ts +2 -0
- package/package.json +4 -4
- package/src/Carousel/CarouselNative.tsx +2 -2
- package/src/FlipCard/FlipCard.tsx +67 -0
- package/src/FlipCard/FlipCardProps.ts +19 -0
- package/src/FlipCard/index.ts +2 -0
- package/src/index.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.18.0](https://github.com/tappytoon/tappytoon/compare/@fountain-ui/lab@1.13.0...@fountain-ui/lab@1.18.0) (2022-03-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @fountain-ui/lab
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [1.17.0](https://github.com/tappytoon/tappytoon/compare/@fountain-ui/lab@1.13.0...@fountain-ui/lab@1.17.0) (2022-01-25)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @fountain-ui/lab
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.16.2](https://github.com/tappytoon/tappytoon/compare/@fountain-ui/lab@1.13.0...@fountain-ui/lab@1.16.2) (2022-01-13)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @fountain-ui/lab
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## [1.16.1](https://github.com/tappytoon/tappytoon/compare/@fountain-ui/lab@1.13.0...@fountain-ui/lab@1.16.1) (2022-01-07)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @fountain-ui/lab
|
|
@@ -7,10 +7,10 @@ exports.default = Carousel;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
10
|
var _reactNativeSnapCarousel = _interopRequireDefault(require("react-native-snap-carousel"));
|
|
13
11
|
|
|
12
|
+
var _core = require("@fountain-ui/core");
|
|
13
|
+
|
|
14
14
|
var _utils = require("./utils");
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -31,7 +31,7 @@ function Carousel(props) {
|
|
|
31
31
|
|
|
32
32
|
const carouselRef = _react.default.useRef(null);
|
|
33
33
|
|
|
34
|
-
const window = (0,
|
|
34
|
+
const window = (0, _core.useValidWindowDimensions)();
|
|
35
35
|
const sliderWidth = window.width;
|
|
36
36
|
const itemWidth = centerSlidePadding !== undefined ? sliderWidth - centerSlidePadding * 2 : sliderWidth;
|
|
37
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselNative.tsx"],"names":["Carousel","props","autoplay","defaultAutoplay","autoplayInterval","defaultAutoplayInterval","centerSlidePadding","data","inactiveSlideOpacity","defaultInactiveSlideOpacity","inactiveSlideScale","defaultInactiveSlideScale","index","infinite","defaultInfinite","onChange","renderItem","carouselRef","React","useRef","window","sliderWidth","width","itemWidth","undefined","useEffect","carousel","current","currentIndex","snapToItem","handleSnapToItem","newIndex"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAQe,SAASA,QAAT,CAAyBC,KAAzB,EAAsD;AACjE,QAAM;AACFC,IAAAA,QAAQ,GAAGC,sBADT;AAEFC,IAAAA,gBAAgB,GAAGC,8BAFjB;AAGFC,IAAAA,kBAHE;AAIFC,IAAAA,IAJE;AAKFC,IAAAA,oBAAoB,GAAGC,kCALrB;AAMFC,IAAAA,kBAAkB,GAAGC,gCANnB;AAOFC,IAAAA,KAPE;AAQFC,IAAAA,QAAQ,GAAGC,sBART;AASFC,IAAAA,QATE;AAUFC,IAAAA;AAVE,MAWFf,KAXJ;;AAaA,QAAMgB,WAAW,GAAGC,eAAMC,MAAN,CAA2C,IAA3C,CAApB;;AAEA,QAAMC,MAAM,GAAG,
|
|
1
|
+
{"version":3,"sources":["CarouselNative.tsx"],"names":["Carousel","props","autoplay","defaultAutoplay","autoplayInterval","defaultAutoplayInterval","centerSlidePadding","data","inactiveSlideOpacity","defaultInactiveSlideOpacity","inactiveSlideScale","defaultInactiveSlideScale","index","infinite","defaultInfinite","onChange","renderItem","carouselRef","React","useRef","window","sliderWidth","width","itemWidth","undefined","useEffect","carousel","current","currentIndex","snapToItem","handleSnapToItem","newIndex"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;A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AEa,SAPf;AAQI,IAAA,IAAI,EAAEV,QARV;AASI,IAAA,iBAAiB,EAAE,CATvB;AAUI,IAAA,YAAY,EAAEiB,gBAVlB;AAWI,IAAA,GAAG,EAAEb,WAXT;AAYI,IAAA,UAAU,EAAED,UAZhB;AAaI,IAAA,WAAW,EAAEK;AAbjB,IADJ;AAiBH;;AAAA","sourcesContent":["import React from 'react';\nimport RNSnapCarousel from 'react-native-snap-carousel';\nimport { useValidWindowDimensions } from '@fountain-ui/core';\nimport type CarouselProps from './CarouselProps';\nimport {\n defaultAutoplay,\n defaultAutoplayInterval,\n defaultInactiveSlideOpacity,\n defaultInactiveSlideScale,\n defaultInfinite,\n} from './utils';\n\nexport default function Carousel<ItemT>(props: CarouselProps<ItemT>) {\n const {\n autoplay = defaultAutoplay,\n autoplayInterval = defaultAutoplayInterval,\n centerSlidePadding,\n data,\n inactiveSlideOpacity = defaultInactiveSlideOpacity,\n inactiveSlideScale = defaultInactiveSlideScale,\n index,\n infinite = defaultInfinite,\n onChange,\n renderItem,\n } = props;\n\n const carouselRef = React.useRef<RNSnapCarousel<ItemT> | null>(null);\n\n const window = useValidWindowDimensions();\n const sliderWidth = window.width;\n const itemWidth = centerSlidePadding !== undefined\n ? sliderWidth - (centerSlidePadding * 2)\n : sliderWidth;\n\n React.useEffect(() => {\n const carousel = carouselRef.current;\n if (carousel && index !== carousel.currentIndex) {\n carousel.snapToItem(index, true);\n }\n }, [index]);\n\n const handleSnapToItem = (newIndex: number) => {\n if (onChange) {\n onChange(newIndex);\n }\n };\n\n return (\n <RNSnapCarousel\n autoplay={autoplay}\n autoplayInterval={autoplayInterval}\n data={data}\n horizontal={true}\n inactiveSlideOpacity={inactiveSlideOpacity}\n inactiveSlideScale={inactiveSlideScale}\n itemWidth={itemWidth}\n loop={infinite}\n loopClonesPerSide={2}\n onSnapToItem={handleSnapToItem}\n ref={carouselRef}\n renderItem={renderItem}\n sliderWidth={sliderWidth}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = FlipCard;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
const styles = _reactNative.StyleSheet.create({
|
|
21
|
+
container: {
|
|
22
|
+
height: 32,
|
|
23
|
+
width: 24
|
|
24
|
+
},
|
|
25
|
+
animatedCard: {
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
position: 'absolute'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const PERSPECTIVE = 100;
|
|
33
|
+
const Z_INDEX_CHANGE_ANGLE = 90;
|
|
34
|
+
|
|
35
|
+
function FlipCard(props) {
|
|
36
|
+
const {
|
|
37
|
+
backCard,
|
|
38
|
+
frontCard,
|
|
39
|
+
reanimationKey,
|
|
40
|
+
style
|
|
41
|
+
} = props;
|
|
42
|
+
|
|
43
|
+
const sharedAngle = _reactNativeReanimated.default.useSharedValue(0);
|
|
44
|
+
|
|
45
|
+
const animatedFrontCardStyle = _reactNativeReanimated.default.useAnimatedStyle(() => {
|
|
46
|
+
return {
|
|
47
|
+
zIndex: sharedAngle.value < Z_INDEX_CHANGE_ANGLE ? 2 : 1,
|
|
48
|
+
transform: [{
|
|
49
|
+
perspective: PERSPECTIVE
|
|
50
|
+
}, {
|
|
51
|
+
rotateX: `${sharedAngle.value}deg`
|
|
52
|
+
}]
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const animatedBackCardStyle = _reactNativeReanimated.default.useAnimatedStyle(() => {
|
|
57
|
+
return {
|
|
58
|
+
zIndex: sharedAngle.value <= Z_INDEX_CHANGE_ANGLE ? 1 : 2,
|
|
59
|
+
transform: [{
|
|
60
|
+
perspective: PERSPECTIVE
|
|
61
|
+
}, {
|
|
62
|
+
rotateX: `${sharedAngle.value + 180}deg`
|
|
63
|
+
}]
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
(0, _react.useEffect)(() => {
|
|
68
|
+
sharedAngle.value = 0;
|
|
69
|
+
sharedAngle.value = _reactNativeReanimated.default.withTiming(180, {
|
|
70
|
+
duration: 500
|
|
71
|
+
});
|
|
72
|
+
}, [reanimationKey]);
|
|
73
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
74
|
+
style: [styles.container, style]
|
|
75
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
76
|
+
style: [styles.animatedCard, animatedFrontCardStyle]
|
|
77
|
+
}, frontCard), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
78
|
+
style: [styles.animatedCard, animatedBackCardStyle]
|
|
79
|
+
}, backCard));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
;
|
|
83
|
+
//# sourceMappingURL=FlipCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FlipCard.tsx"],"names":["styles","StyleSheet","create","container","height","width","animatedCard","alignItems","justifyContent","position","PERSPECTIVE","Z_INDEX_CHANGE_ANGLE","FlipCard","props","backCard","frontCard","reanimationKey","style","sharedAngle","Animated","useSharedValue","animatedFrontCardStyle","useAnimatedStyle","zIndex","value","transform","perspective","rotateX","animatedBackCardStyle","withTiming","duration"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;AAGA,MAAMA,MAAM,GAAGC,wBAAWC,MAAX,CAAkB;AAC7BC,EAAAA,SAAS,EAAE;AACPC,IAAAA,MAAM,EAAE,EADD;AAEPC,IAAAA,KAAK,EAAE;AAFA,GADkB;AAK7BC,EAAAA,YAAY,EAAE;AACVC,IAAAA,UAAU,EAAE,QADF;AAEVC,IAAAA,cAAc,EAAE,QAFN;AAGVC,IAAAA,QAAQ,EAAE;AAHA;AALe,CAAlB,CAAf;;AAYA,MAAMC,WAAW,GAAG,GAApB;AACA,MAAMC,oBAAoB,GAAG,EAA7B;;AAEe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;AACnD,QAAM;AACFC,IAAAA,QADE;AAEFC,IAAAA,SAFE;AAGFC,IAAAA,cAHE;AAIFC,IAAAA;AAJE,MAKFJ,KALJ;;AAOA,QAAMK,WAAW,GAAGC,+BAASC,cAAT,CAAwB,CAAxB,CAApB;;AAEA,QAAMC,sBAAsB,GAAGF,+BAASG,gBAAT,CAA0B,MAAM;AAC3D,WAAO;AACHC,MAAAA,MAAM,EAAEL,WAAW,CAACM,KAAZ,GAAoBb,oBAApB,GAA2C,CAA3C,GAA+C,CADpD;AAEHc,MAAAA,SAAS,EAAE,CACP;AAAEC,QAAAA,WAAW,EAAEhB;AAAf,OADO,EAEP;AAAEiB,QAAAA,OAAO,EAAG,GAAET,WAAW,CAACM,KAAM;AAAhC,OAFO;AAFR,KAAP;AAOH,GAR8B,CAA/B;;AAUA,QAAMI,qBAAqB,GAAGT,+BAASG,gBAAT,CAA0B,MAAM;AAC1D,WAAO;AACHC,MAAAA,MAAM,EAAEL,WAAW,CAACM,KAAZ,IAAqBb,oBAArB,GAA4C,CAA5C,GAAgD,CADrD;AAEHc,MAAAA,SAAS,EAAE,CACP;AAAEC,QAAAA,WAAW,EAAEhB;AAAf,OADO,EAEP;AAAEiB,QAAAA,OAAO,EAAG,GAAGT,WAAW,CAACM,KAAZ,GAAoB,GAAK;AAAxC,OAFO;AAFR,KAAP;AAOH,GAR6B,CAA9B;;AAUA,wBAAU,MAAM;AACZN,IAAAA,WAAW,CAACM,KAAZ,GAAoB,CAApB;AACAN,IAAAA,WAAW,CAACM,KAAZ,GAAoBL,+BAASU,UAAT,CAAoB,GAApB,EAAyB;AAAEC,MAAAA,QAAQ,EAAE;AAAZ,KAAzB,CAApB;AACH,GAHD,EAGG,CAACd,cAAD,CAHH;AAKA,sBACI,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAE,CAAChB,MAAM,CAACG,SAAR,EAAmBc,KAAnB;AAAb,kBACI,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAE,CAACjB,MAAM,CAACM,YAAR,EAAsBe,sBAAtB;AAAtB,KACKN,SADL,CADJ,eAKI,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAE,CAACf,MAAM,CAACM,YAAR,EAAsBsB,qBAAtB;AAAtB,KACKd,QADL,CALJ,CADJ;AAWH;;AAAA","sourcesContent":["import React, { useEffect } from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport type FlipCardProps from './FlipCardProps';\n\nconst styles = StyleSheet.create({\n container: {\n height: 32,\n width: 24,\n },\n animatedCard: {\n alignItems: 'center',\n justifyContent: 'center',\n position: 'absolute',\n },\n});\n\nconst PERSPECTIVE = 100;\nconst Z_INDEX_CHANGE_ANGLE = 90;\n\nexport default function FlipCard(props: FlipCardProps) {\n const {\n backCard,\n frontCard,\n reanimationKey,\n style,\n } = props;\n\n const sharedAngle = Animated.useSharedValue(0);\n\n const animatedFrontCardStyle = Animated.useAnimatedStyle(() => {\n return {\n zIndex: sharedAngle.value < Z_INDEX_CHANGE_ANGLE ? 2 : 1,\n transform: [\n { perspective: PERSPECTIVE },\n { rotateX: `${sharedAngle.value}deg` },\n ],\n };\n });\n\n const animatedBackCardStyle = Animated.useAnimatedStyle(() => {\n return {\n zIndex: sharedAngle.value <= Z_INDEX_CHANGE_ANGLE ? 1 : 2,\n transform: [\n { perspective: PERSPECTIVE },\n { rotateX: `${(sharedAngle.value + 180)}deg` },\n ],\n };\n });\n\n useEffect(() => {\n sharedAngle.value = 0;\n sharedAngle.value = Animated.withTiming(180, { duration: 500 });\n }, [reanimationKey]);\n\n return (\n <View style={[styles.container, style]}>\n <Animated.View style={[styles.animatedCard, animatedFrontCardStyle]}>\n {frontCard}\n </Animated.View>\n\n <Animated.View style={[styles.animatedCard, animatedBackCardStyle]}>\n {backCard}\n </Animated.View>\n </View>\n );\n};"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _FlipCard.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _FlipCard = _interopRequireDefault(require("./FlipCard"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { default } from './FlipCard';\nexport type { default as FlipCardProps } from './FlipCardProps';"]}
|
package/build/commonjs/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var _exportNames = {
|
|
|
7
7
|
BottomSheet: true,
|
|
8
8
|
Carousel: true,
|
|
9
9
|
DateTimePicker: true,
|
|
10
|
+
FlipCard: true,
|
|
10
11
|
ViewPager: true,
|
|
11
12
|
StatusBarProvider: true,
|
|
12
13
|
useStatusBarContext: true
|
|
@@ -29,6 +30,12 @@ Object.defineProperty(exports, "DateTimePicker", {
|
|
|
29
30
|
return _DateTimePicker.default;
|
|
30
31
|
}
|
|
31
32
|
});
|
|
33
|
+
Object.defineProperty(exports, "FlipCard", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _FlipCard.default;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
32
39
|
Object.defineProperty(exports, "ViewPager", {
|
|
33
40
|
enumerable: true,
|
|
34
41
|
get: function () {
|
|
@@ -90,6 +97,20 @@ Object.keys(_DateTimePicker).forEach(function (key) {
|
|
|
90
97
|
});
|
|
91
98
|
});
|
|
92
99
|
|
|
100
|
+
var _FlipCard = _interopRequireWildcard(require("./FlipCard"));
|
|
101
|
+
|
|
102
|
+
Object.keys(_FlipCard).forEach(function (key) {
|
|
103
|
+
if (key === "default" || key === "__esModule") return;
|
|
104
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
105
|
+
if (key in exports && exports[key] === _FlipCard[key]) return;
|
|
106
|
+
Object.defineProperty(exports, key, {
|
|
107
|
+
enumerable: true,
|
|
108
|
+
get: function () {
|
|
109
|
+
return _FlipCard[key];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
93
114
|
var _ViewPager = _interopRequireWildcard(require("./ViewPager"));
|
|
94
115
|
|
|
95
116
|
Object.keys(_ViewPager).forEach(function (key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export { default as BottomSheet } from './BottomSheet';\nexport * from './BottomSheet';\n\nexport { default as Carousel } from './Carousel';\nexport * from './Carousel';\n\nexport { default as DateTimePicker } from './DateTimePicker';\nexport * from './DateTimePicker';\n\nexport { default as FlipCard } from './FlipCard';\nexport * from './FlipCard';\n\nexport { default as ViewPager } from './ViewPager';\nexport * from './ViewPager';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport * from './hooks';\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useWindowDimensions } from 'react-native';
|
|
3
2
|
import RNSnapCarousel from 'react-native-snap-carousel';
|
|
3
|
+
import { useValidWindowDimensions } from '@fountain-ui/core';
|
|
4
4
|
import { defaultAutoplay, defaultAutoplayInterval, defaultInactiveSlideOpacity, defaultInactiveSlideScale, defaultInfinite } from './utils';
|
|
5
5
|
export default function Carousel(props) {
|
|
6
6
|
const {
|
|
@@ -16,7 +16,7 @@ export default function Carousel(props) {
|
|
|
16
16
|
renderItem
|
|
17
17
|
} = props;
|
|
18
18
|
const carouselRef = React.useRef(null);
|
|
19
|
-
const window =
|
|
19
|
+
const window = useValidWindowDimensions();
|
|
20
20
|
const sliderWidth = window.width;
|
|
21
21
|
const itemWidth = centerSlidePadding !== undefined ? sliderWidth - centerSlidePadding * 2 : sliderWidth;
|
|
22
22
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CarouselNative.tsx"],"names":["React","
|
|
1
|
+
{"version":3,"sources":["CarouselNative.tsx"],"names":["React","RNSnapCarousel","useValidWindowDimensions","defaultAutoplay","defaultAutoplayInterval","defaultInactiveSlideOpacity","defaultInactiveSlideScale","defaultInfinite","Carousel","props","autoplay","autoplayInterval","centerSlidePadding","data","inactiveSlideOpacity","inactiveSlideScale","index","infinite","onChange","renderItem","carouselRef","useRef","window","sliderWidth","width","itemWidth","undefined","useEffect","carousel","current","currentIndex","snapToItem","handleSnapToItem","newIndex"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,cAAP,MAA2B,4BAA3B;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AAEA,SACIC,eADJ,EAEIC,uBAFJ,EAGIC,2BAHJ,EAIIC,yBAJJ,EAKIC,eALJ,QAMO,SANP;AAQA,eAAe,SAASC,QAAT,CAAyBC,KAAzB,EAAsD;AACjE,QAAM;AACFC,IAAAA,QAAQ,GAAGP,eADT;AAEFQ,IAAAA,gBAAgB,GA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gBAVlB;AAWI,IAAA,GAAG,EAAEZ,WAXT;AAYI,IAAA,UAAU,EAAED,UAZhB;AAaI,IAAA,WAAW,EAAEI;AAbjB,IADJ;AAiBH;AAAA","sourcesContent":["import React from 'react';\nimport RNSnapCarousel from 'react-native-snap-carousel';\nimport { useValidWindowDimensions } from '@fountain-ui/core';\nimport type CarouselProps from './CarouselProps';\nimport {\n defaultAutoplay,\n defaultAutoplayInterval,\n defaultInactiveSlideOpacity,\n defaultInactiveSlideScale,\n defaultInfinite,\n} from './utils';\n\nexport default function Carousel<ItemT>(props: CarouselProps<ItemT>) {\n const {\n autoplay = defaultAutoplay,\n autoplayInterval = defaultAutoplayInterval,\n centerSlidePadding,\n data,\n inactiveSlideOpacity = defaultInactiveSlideOpacity,\n inactiveSlideScale = defaultInactiveSlideScale,\n index,\n infinite = defaultInfinite,\n onChange,\n renderItem,\n } = props;\n\n const carouselRef = React.useRef<RNSnapCarousel<ItemT> | null>(null);\n\n const window = useValidWindowDimensions();\n const sliderWidth = window.width;\n const itemWidth = centerSlidePadding !== undefined\n ? sliderWidth - (centerSlidePadding * 2)\n : sliderWidth;\n\n React.useEffect(() => {\n const carousel = carouselRef.current;\n if (carousel && index !== carousel.currentIndex) {\n carousel.snapToItem(index, true);\n }\n }, [index]);\n\n const handleSnapToItem = (newIndex: number) => {\n if (onChange) {\n onChange(newIndex);\n }\n };\n\n return (\n <RNSnapCarousel\n autoplay={autoplay}\n autoplayInterval={autoplayInterval}\n data={data}\n horizontal={true}\n inactiveSlideOpacity={inactiveSlideOpacity}\n inactiveSlideScale={inactiveSlideScale}\n itemWidth={itemWidth}\n loop={infinite}\n loopClonesPerSide={2}\n onSnapToItem={handleSnapToItem}\n ref={carouselRef}\n renderItem={renderItem}\n sliderWidth={sliderWidth}\n />\n );\n};\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
4
|
+
const styles = StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
height: 32,
|
|
7
|
+
width: 24
|
|
8
|
+
},
|
|
9
|
+
animatedCard: {
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent: 'center',
|
|
12
|
+
position: 'absolute'
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const PERSPECTIVE = 100;
|
|
16
|
+
const Z_INDEX_CHANGE_ANGLE = 90;
|
|
17
|
+
export default function FlipCard(props) {
|
|
18
|
+
const {
|
|
19
|
+
backCard,
|
|
20
|
+
frontCard,
|
|
21
|
+
reanimationKey,
|
|
22
|
+
style
|
|
23
|
+
} = props;
|
|
24
|
+
const sharedAngle = Animated.useSharedValue(0);
|
|
25
|
+
const animatedFrontCardStyle = Animated.useAnimatedStyle(() => {
|
|
26
|
+
return {
|
|
27
|
+
zIndex: sharedAngle.value < Z_INDEX_CHANGE_ANGLE ? 2 : 1,
|
|
28
|
+
transform: [{
|
|
29
|
+
perspective: PERSPECTIVE
|
|
30
|
+
}, {
|
|
31
|
+
rotateX: `${sharedAngle.value}deg`
|
|
32
|
+
}]
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
const animatedBackCardStyle = Animated.useAnimatedStyle(() => {
|
|
36
|
+
return {
|
|
37
|
+
zIndex: sharedAngle.value <= Z_INDEX_CHANGE_ANGLE ? 1 : 2,
|
|
38
|
+
transform: [{
|
|
39
|
+
perspective: PERSPECTIVE
|
|
40
|
+
}, {
|
|
41
|
+
rotateX: `${sharedAngle.value + 180}deg`
|
|
42
|
+
}]
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
sharedAngle.value = 0;
|
|
47
|
+
sharedAngle.value = Animated.withTiming(180, {
|
|
48
|
+
duration: 500
|
|
49
|
+
});
|
|
50
|
+
}, [reanimationKey]);
|
|
51
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
52
|
+
style: [styles.container, style]
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
54
|
+
style: [styles.animatedCard, animatedFrontCardStyle]
|
|
55
|
+
}, frontCard), /*#__PURE__*/React.createElement(Animated.View, {
|
|
56
|
+
style: [styles.animatedCard, animatedBackCardStyle]
|
|
57
|
+
}, backCard));
|
|
58
|
+
}
|
|
59
|
+
;
|
|
60
|
+
//# sourceMappingURL=FlipCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FlipCard.tsx"],"names":["React","useEffect","StyleSheet","View","Animated","styles","create","container","height","width","animatedCard","alignItems","justifyContent","position","PERSPECTIVE","Z_INDEX_CHANGE_ANGLE","FlipCard","props","backCard","frontCard","reanimationKey","style","sharedAngle","useSharedValue","animatedFrontCardStyle","useAnimatedStyle","zIndex","value","transform","perspective","rotateX","animatedBackCardStyle","withTiming","duration"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AACA,OAAOC,QAAP,MAAqB,yBAArB;AAGA,MAAMC,MAAM,GAAGH,UAAU,CAACI,MAAX,CAAkB;AAC7BC,EAAAA,SAAS,EAAE;AACPC,IAAAA,MAAM,EAAE,EADD;AAEPC,IAAAA,KAAK,EAAE;AAFA,GADkB;AAK7BC,EAAAA,YAAY,EAAE;AACVC,IAAAA,UAAU,EAAE,QADF;AAEVC,IAAAA,cAAc,EAAE,QAFN;AAGVC,IAAAA,QAAQ,EAAE;AAHA;AALe,CAAlB,CAAf;AAYA,MAAMC,WAAW,GAAG,GAApB;AACA,MAAMC,oBAAoB,GAAG,EAA7B;AAEA,eAAe,SAASC,QAAT,CAAkBC,KAAlB,EAAwC;AACnD,QAAM;AACFC,IAAAA,QADE;AAEFC,IAAAA,SAFE;AAGFC,IAAAA,cAHE;AAIFC,IAAAA;AAJE,MAKFJ,KALJ;AAOA,QAAMK,WAAW,GAAGlB,QAAQ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U,IAAV;AAAe,IAAA,KAAK,EAAE,CAACd,MAAM,CAACK,YAAR,EAAsBqB,qBAAtB;AAAtB,KACKb,QADL,CALJ,CADJ;AAWH;AAAA","sourcesContent":["import React, { useEffect } from 'react';\nimport { StyleSheet, View } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport type FlipCardProps from './FlipCardProps';\n\nconst styles = StyleSheet.create({\n container: {\n height: 32,\n width: 24,\n },\n animatedCard: {\n alignItems: 'center',\n justifyContent: 'center',\n position: 'absolute',\n },\n});\n\nconst PERSPECTIVE = 100;\nconst Z_INDEX_CHANGE_ANGLE = 90;\n\nexport default function FlipCard(props: FlipCardProps) {\n const {\n backCard,\n frontCard,\n reanimationKey,\n style,\n } = props;\n\n const sharedAngle = Animated.useSharedValue(0);\n\n const animatedFrontCardStyle = Animated.useAnimatedStyle(() => {\n return {\n zIndex: sharedAngle.value < Z_INDEX_CHANGE_ANGLE ? 2 : 1,\n transform: [\n { perspective: PERSPECTIVE },\n { rotateX: `${sharedAngle.value}deg` },\n ],\n };\n });\n\n const animatedBackCardStyle = Animated.useAnimatedStyle(() => {\n return {\n zIndex: sharedAngle.value <= Z_INDEX_CHANGE_ANGLE ? 1 : 2,\n transform: [\n { perspective: PERSPECTIVE },\n { rotateX: `${(sharedAngle.value + 180)}deg` },\n ],\n };\n });\n\n useEffect(() => {\n sharedAngle.value = 0;\n sharedAngle.value = Animated.withTiming(180, { duration: 500 });\n }, [reanimationKey]);\n\n return (\n <View style={[styles.container, style]}>\n <Animated.View style={[styles.animatedCard, animatedFrontCardStyle]}>\n {frontCard}\n </Animated.View>\n\n <Animated.View style={[styles.animatedCard, animatedBackCardStyle]}>\n {backCard}\n </Animated.View>\n </View>\n );\n};"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,YAAxB","sourcesContent":["export { default } from './FlipCard';\nexport type { default as FlipCardProps } from './FlipCardProps';"]}
|
package/build/module/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export { default as Carousel } from './Carousel';
|
|
|
4
4
|
export * from './Carousel';
|
|
5
5
|
export { default as DateTimePicker } from './DateTimePicker';
|
|
6
6
|
export * from './DateTimePicker';
|
|
7
|
+
export { default as FlipCard } from './FlipCard';
|
|
8
|
+
export * from './FlipCard';
|
|
7
9
|
export { default as ViewPager } from './ViewPager';
|
|
8
10
|
export * from './ViewPager';
|
|
9
11
|
export { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["default","BottomSheet","Carousel","DateTimePicker","ViewPager","StatusBarProvider","useStatusBarContext"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASF,OAAO,IAAIG,cAApB,QAA0C,kBAA1C;AACA,cAAc,kBAAd;AAEA,SAASH,OAAO,IAAII,SAApB,QAAqC,aAArC;AACA,cAAc,aAAd;AAEA,
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","StatusBarProvider","useStatusBarContext"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASF,OAAO,IAAIG,cAApB,QAA0C,kBAA1C;AACA,cAAc,kBAAd;AAEA,SAASH,OAAO,IAAII,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASJ,OAAO,IAAIK,SAApB,QAAqC,aAArC;AACA,cAAc,aAAd;AAEA,SAASL,OAAO,IAAIM,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,cAAc,SAAd","sourcesContent":["export { default as BottomSheet } from './BottomSheet';\nexport * from './BottomSheet';\n\nexport { default as Carousel } from './Carousel';\nexport * from './Carousel';\n\nexport { default as DateTimePicker } from './DateTimePicker';\nexport * from './DateTimePicker';\n\nexport { default as FlipCard } from './FlipCard';\nexport * from './FlipCard';\n\nexport { default as ViewPager } from './ViewPager';\nexport * from './ViewPager';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport * from './hooks';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentProps } from '@fountain-ui/core';
|
|
3
|
+
export default interface FlipCardProps extends ComponentProps<{
|
|
4
|
+
/**
|
|
5
|
+
* Element placed on backSide
|
|
6
|
+
*/
|
|
7
|
+
backCard: React.ReactElement;
|
|
8
|
+
/**
|
|
9
|
+
* Element placed on frontSide
|
|
10
|
+
*/
|
|
11
|
+
frontCard: React.ReactElement;
|
|
12
|
+
/**
|
|
13
|
+
* The key to reanimate Component, usually includes card content
|
|
14
|
+
*/
|
|
15
|
+
reanimationKey?: string;
|
|
16
|
+
}> {
|
|
17
|
+
}
|
|
@@ -4,6 +4,8 @@ export { default as Carousel } from './Carousel';
|
|
|
4
4
|
export * from './Carousel';
|
|
5
5
|
export { default as DateTimePicker } from './DateTimePicker';
|
|
6
6
|
export * from './DateTimePicker';
|
|
7
|
+
export { default as FlipCard } from './FlipCard';
|
|
8
|
+
export * from './FlipCard';
|
|
7
9
|
export { default as ViewPager } from './ViewPager';
|
|
8
10
|
export * from './ViewPager';
|
|
9
11
|
export { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fountain-ui/lab",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Fountain-UI Team",
|
|
6
6
|
"description": "Incubator for Fountain-UI React components.",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@emotion/react": "^11.4.1",
|
|
19
19
|
"@emotion/styled": "^11.0.0",
|
|
20
|
-
"@fountain-ui/icons": "^1.
|
|
20
|
+
"@fountain-ui/icons": "^1.17.0",
|
|
21
21
|
"@fountain-ui/utils": "^1.1.0",
|
|
22
22
|
"react-native-calendars": "1.1267.0"
|
|
23
23
|
},
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@fountain-ui/core": "^1.
|
|
56
|
+
"@fountain-ui/core": "^1.16.0",
|
|
57
57
|
"@gorhom/bottom-sheet": "4.1.3",
|
|
58
58
|
"@react-native-community/viewpager": "^4.2.2",
|
|
59
59
|
"@types/react-native-snap-carousel": "^3.8.4",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "0738cec018c008c9993b8d432ca8aaa44d7c3f77"
|
|
89
89
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useWindowDimensions } from 'react-native';
|
|
3
2
|
import RNSnapCarousel from 'react-native-snap-carousel';
|
|
3
|
+
import { useValidWindowDimensions } from '@fountain-ui/core';
|
|
4
4
|
import type CarouselProps from './CarouselProps';
|
|
5
5
|
import {
|
|
6
6
|
defaultAutoplay,
|
|
@@ -26,7 +26,7 @@ export default function Carousel<ItemT>(props: CarouselProps<ItemT>) {
|
|
|
26
26
|
|
|
27
27
|
const carouselRef = React.useRef<RNSnapCarousel<ItemT> | null>(null);
|
|
28
28
|
|
|
29
|
-
const window =
|
|
29
|
+
const window = useValidWindowDimensions();
|
|
30
30
|
const sliderWidth = window.width;
|
|
31
31
|
const itemWidth = centerSlidePadding !== undefined
|
|
32
32
|
? sliderWidth - (centerSlidePadding * 2)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import Animated from 'react-native-reanimated';
|
|
4
|
+
import type FlipCardProps from './FlipCardProps';
|
|
5
|
+
|
|
6
|
+
const styles = StyleSheet.create({
|
|
7
|
+
container: {
|
|
8
|
+
height: 32,
|
|
9
|
+
width: 24,
|
|
10
|
+
},
|
|
11
|
+
animatedCard: {
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
position: 'absolute',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const PERSPECTIVE = 100;
|
|
19
|
+
const Z_INDEX_CHANGE_ANGLE = 90;
|
|
20
|
+
|
|
21
|
+
export default function FlipCard(props: FlipCardProps) {
|
|
22
|
+
const {
|
|
23
|
+
backCard,
|
|
24
|
+
frontCard,
|
|
25
|
+
reanimationKey,
|
|
26
|
+
style,
|
|
27
|
+
} = props;
|
|
28
|
+
|
|
29
|
+
const sharedAngle = Animated.useSharedValue(0);
|
|
30
|
+
|
|
31
|
+
const animatedFrontCardStyle = Animated.useAnimatedStyle(() => {
|
|
32
|
+
return {
|
|
33
|
+
zIndex: sharedAngle.value < Z_INDEX_CHANGE_ANGLE ? 2 : 1,
|
|
34
|
+
transform: [
|
|
35
|
+
{ perspective: PERSPECTIVE },
|
|
36
|
+
{ rotateX: `${sharedAngle.value}deg` },
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const animatedBackCardStyle = Animated.useAnimatedStyle(() => {
|
|
42
|
+
return {
|
|
43
|
+
zIndex: sharedAngle.value <= Z_INDEX_CHANGE_ANGLE ? 1 : 2,
|
|
44
|
+
transform: [
|
|
45
|
+
{ perspective: PERSPECTIVE },
|
|
46
|
+
{ rotateX: `${(sharedAngle.value + 180)}deg` },
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
sharedAngle.value = 0;
|
|
53
|
+
sharedAngle.value = Animated.withTiming(180, { duration: 500 });
|
|
54
|
+
}, [reanimationKey]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<View style={[styles.container, style]}>
|
|
58
|
+
<Animated.View style={[styles.animatedCard, animatedFrontCardStyle]}>
|
|
59
|
+
{frontCard}
|
|
60
|
+
</Animated.View>
|
|
61
|
+
|
|
62
|
+
<Animated.View style={[styles.animatedCard, animatedBackCardStyle]}>
|
|
63
|
+
{backCard}
|
|
64
|
+
</Animated.View>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentProps } from '@fountain-ui/core';
|
|
3
|
+
|
|
4
|
+
export default interface FlipCardProps extends ComponentProps<{
|
|
5
|
+
/**
|
|
6
|
+
* Element placed on backSide
|
|
7
|
+
*/
|
|
8
|
+
backCard: React.ReactElement;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Element placed on frontSide
|
|
12
|
+
*/
|
|
13
|
+
frontCard: React.ReactElement;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The key to reanimate Component, usually includes card content
|
|
17
|
+
*/
|
|
18
|
+
reanimationKey?: string;
|
|
19
|
+
}> {}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,9 @@ export * from './Carousel';
|
|
|
7
7
|
export { default as DateTimePicker } from './DateTimePicker';
|
|
8
8
|
export * from './DateTimePicker';
|
|
9
9
|
|
|
10
|
+
export { default as FlipCard } from './FlipCard';
|
|
11
|
+
export * from './FlipCard';
|
|
12
|
+
|
|
10
13
|
export { default as ViewPager } from './ViewPager';
|
|
11
14
|
export * from './ViewPager';
|
|
12
15
|
|