@fountain-ui/lab 2.0.0-beta.11 → 2.0.0-beta.12
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/build/commonjs/Carousel/Carousel.js +137 -0
- package/build/commonjs/Carousel/Carousel.js.map +1 -0
- package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
- package/build/commonjs/Carousel/animation/animationUtils.js +9 -0
- package/build/commonjs/Carousel/animation/animationUtils.js.map +1 -0
- package/build/commonjs/Carousel/animation/createDefaultItemStyle.js +15 -0
- package/build/commonjs/Carousel/animation/createDefaultItemStyle.js.map +1 -0
- package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js +20 -0
- package/build/commonjs/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
- package/build/commonjs/Carousel/animation/index.js +40 -0
- package/build/commonjs/Carousel/animation/index.js.map +1 -0
- package/build/commonjs/Carousel/animation/normalItemStyleFactory.js +27 -0
- package/build/commonjs/Carousel/animation/normalItemStyleFactory.js.map +1 -0
- package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js +65 -0
- package/build/commonjs/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
- package/build/commonjs/Carousel/components/InternalContext.js +29 -0
- package/build/commonjs/Carousel/components/InternalContext.js.map +1 -0
- package/build/commonjs/Carousel/components/ItemView.js +64 -0
- package/build/commonjs/Carousel/components/ItemView.js.map +1 -0
- package/build/commonjs/Carousel/components/RootView.js +68 -0
- package/build/commonjs/Carousel/components/RootView.js.map +1 -0
- package/build/commonjs/Carousel/components/ScrollViewGesture.js +76 -0
- package/build/commonjs/Carousel/components/ScrollViewGesture.js.map +1 -0
- package/build/commonjs/Carousel/components/index.js +40 -0
- package/build/commonjs/Carousel/components/index.js.map +1 -0
- package/build/commonjs/Carousel/hooks/index.js +64 -0
- package/build/commonjs/Carousel/hooks/index.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useAutoplayController.js +55 -0
- package/build/commonjs/Carousel/hooks/useAutoplayController.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useDimensionChangeReaction.js +23 -0
- package/build/commonjs/Carousel/hooks/useDimensionChangeReaction.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useIndexController.js +70 -0
- package/build/commonjs/Carousel/hooks/useIndexController.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useItemInterpolation.js +63 -0
- package/build/commonjs/Carousel/hooks/useItemInterpolation.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js +95 -0
- package/build/commonjs/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
- package/build/commonjs/Carousel/hooks/useLoopedData.js +33 -0
- package/build/commonjs/Carousel/hooks/useLoopedData.js.map +1 -0
- package/build/commonjs/Carousel/hooks/usePagingAnimation.js +124 -0
- package/build/commonjs/Carousel/hooks/usePagingAnimation.js.map +1 -0
- package/build/commonjs/Carousel/index.js +16 -2
- package/build/commonjs/Carousel/index.js.map +1 -1
- package/build/commonjs/Carousel/types.js +7 -0
- package/build/commonjs/Carousel/types.js.map +1 -0
- package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +44 -47
- package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +1 -1
- package/build/commonjs/ViewPager/PageStateContext.js +22 -0
- package/build/commonjs/ViewPager/PageStateContext.js.map +1 -0
- package/build/commonjs/ViewPager/ViewPagerNative.js +23 -10
- package/build/commonjs/ViewPager/ViewPagerNative.js.map +1 -1
- package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/commonjs/ViewPager/ViewPagerWeb.js +9 -7
- package/build/commonjs/ViewPager/ViewPagerWeb.js.map +1 -1
- package/build/commonjs/ViewPager/index.js +8 -0
- package/build/commonjs/ViewPager/index.js.map +1 -1
- package/build/commonjs/ViewPager/index.native.js +8 -0
- package/build/commonjs/ViewPager/index.native.js.map +1 -1
- package/build/commonjs/ViewPager/utils.js +3 -1
- package/build/commonjs/ViewPager/utils.js.map +1 -1
- package/build/commonjs/ViewabilityTrackerView/Viewability.js +2 -0
- package/build/commonjs/ViewabilityTrackerView/Viewability.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js +45 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
- package/build/commonjs/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
- package/build/commonjs/{Carousel/index.native.js → ViewabilityTrackerView/index.js} +3 -3
- package/build/commonjs/ViewabilityTrackerView/index.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/measureViewability.js +42 -0
- package/build/commonjs/ViewabilityTrackerView/measureViewability.js.map +1 -0
- package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js +88 -0
- package/build/commonjs/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
- package/build/commonjs/hooks/index.js +16 -0
- package/build/commonjs/hooks/index.js.map +1 -1
- package/build/commonjs/hooks/useDeferredExecutor.js +45 -0
- package/build/commonjs/hooks/useDeferredExecutor.js.map +1 -0
- package/build/commonjs/hooks/useIsMounted.js +22 -0
- package/build/commonjs/hooks/useIsMounted.js.map +1 -0
- package/build/commonjs/index.js +22 -1
- package/build/commonjs/index.js.map +1 -1
- package/build/module/Carousel/Carousel.js +115 -0
- package/build/module/Carousel/Carousel.js.map +1 -0
- package/build/module/Carousel/CarouselProps.js.map +1 -1
- package/build/module/Carousel/animation/animationUtils.js +2 -0
- package/build/module/Carousel/animation/animationUtils.js.map +1 -0
- package/build/module/Carousel/animation/createDefaultItemStyle.js +3 -0
- package/build/module/Carousel/animation/createDefaultItemStyle.js.map +1 -0
- package/build/module/Carousel/animation/createDefaultScrollAnimation.js +11 -0
- package/build/module/Carousel/animation/createDefaultScrollAnimation.js.map +1 -0
- package/build/module/Carousel/animation/index.js +5 -0
- package/build/module/Carousel/animation/index.js.map +1 -0
- package/build/module/Carousel/animation/normalItemStyleFactory.js +18 -0
- package/build/module/Carousel/animation/normalItemStyleFactory.js.map +1 -0
- package/build/module/Carousel/animation/parallaxItemStyleFactory.js +55 -0
- package/build/module/Carousel/animation/parallaxItemStyleFactory.js.map +1 -0
- package/build/module/Carousel/components/InternalContext.js +19 -0
- package/build/module/Carousel/components/InternalContext.js.map +1 -0
- package/build/module/Carousel/components/ItemView.js +44 -0
- package/build/module/Carousel/components/ItemView.js.map +1 -0
- package/build/module/Carousel/components/RootView.js +47 -0
- package/build/module/Carousel/components/RootView.js.map +1 -0
- package/build/module/Carousel/components/ScrollViewGesture.js +62 -0
- package/build/module/Carousel/components/ScrollViewGesture.js.map +1 -0
- package/build/module/Carousel/components/index.js +5 -0
- package/build/module/Carousel/components/index.js.map +1 -0
- package/build/module/Carousel/hooks/index.js +8 -0
- package/build/module/Carousel/hooks/index.js.map +1 -0
- package/build/module/Carousel/hooks/useAutoplayController.js +45 -0
- package/build/module/Carousel/hooks/useAutoplayController.js.map +1 -0
- package/build/module/Carousel/hooks/useDimensionChangeReaction.js +14 -0
- package/build/module/Carousel/hooks/useDimensionChangeReaction.js.map +1 -0
- package/build/module/Carousel/hooks/useIndexController.js +54 -0
- package/build/module/Carousel/hooks/useIndexController.js.map +1 -0
- package/build/module/Carousel/hooks/useItemInterpolation.js +51 -0
- package/build/module/Carousel/hooks/useItemInterpolation.js.map +1 -0
- package/build/module/Carousel/hooks/useItemVisibilityStore.js +87 -0
- package/build/module/Carousel/hooks/useItemVisibilityStore.js.map +1 -0
- package/build/module/Carousel/hooks/useLoopedData.js +24 -0
- package/build/module/Carousel/hooks/useLoopedData.js.map +1 -0
- package/build/module/Carousel/hooks/usePagingAnimation.js +115 -0
- package/build/module/Carousel/hooks/usePagingAnimation.js.map +1 -0
- package/build/module/Carousel/index.js +2 -1
- package/build/module/Carousel/index.js.map +1 -1
- package/build/module/Carousel/types.js +3 -0
- package/build/module/Carousel/types.js.map +1 -0
- package/build/module/ViewPager/ChildrenMemoizedPage.js +40 -45
- package/build/module/ViewPager/ChildrenMemoizedPage.js.map +1 -1
- package/build/module/ViewPager/PageStateContext.js +10 -0
- package/build/module/ViewPager/PageStateContext.js.map +1 -0
- package/build/module/ViewPager/ViewPagerNative.js +26 -13
- package/build/module/ViewPager/ViewPagerNative.js.map +1 -1
- package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
- package/build/module/ViewPager/ViewPagerWeb.js +10 -8
- package/build/module/ViewPager/ViewPagerWeb.js.map +1 -1
- package/build/module/ViewPager/index.js +1 -0
- package/build/module/ViewPager/index.js.map +1 -1
- package/build/module/ViewPager/index.native.js +1 -0
- package/build/module/ViewPager/index.native.js.map +1 -1
- package/build/module/ViewPager/utils.js +1 -0
- package/build/module/ViewPager/utils.js.map +1 -1
- package/build/module/ViewabilityTrackerView/Viewability.js +2 -0
- package/build/module/ViewabilityTrackerView/Viewability.js.map +1 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js +28 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerView.js.map +1 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js +2 -0
- package/build/module/ViewabilityTrackerView/ViewabilityTrackerViewProps.js.map +1 -0
- package/build/module/ViewabilityTrackerView/index.js +2 -0
- package/build/module/ViewabilityTrackerView/index.js.map +1 -0
- package/build/module/ViewabilityTrackerView/measureViewability.js +34 -0
- package/build/module/ViewabilityTrackerView/measureViewability.js.map +1 -0
- package/build/module/ViewabilityTrackerView/useViewabilityTracker.js +73 -0
- package/build/module/ViewabilityTrackerView/useViewabilityTracker.js.map +1 -0
- package/build/module/hooks/index.js +2 -0
- package/build/module/hooks/index.js.map +1 -1
- package/build/module/hooks/useDeferredExecutor.js +33 -0
- package/build/module/hooks/useDeferredExecutor.js.map +1 -0
- package/build/module/hooks/useIsMounted.js +13 -0
- package/build/module/hooks/useIsMounted.js.map +1 -0
- package/build/module/index.js +2 -0
- package/build/module/index.js.map +1 -1
- package/build/typescript/Carousel/Carousel.d.ts +5 -0
- package/build/typescript/Carousel/CarouselProps.d.ts +32 -48
- package/build/typescript/Carousel/animation/animationUtils.d.ts +1 -0
- package/build/typescript/Carousel/animation/createDefaultItemStyle.d.ts +2 -0
- package/build/typescript/Carousel/animation/createDefaultScrollAnimation.d.ts +2 -0
- package/build/typescript/Carousel/animation/index.d.ts +4 -0
- package/build/typescript/Carousel/animation/normalItemStyleFactory.d.ts +2 -0
- package/build/typescript/Carousel/animation/parallaxItemStyleFactory.d.ts +9 -0
- package/build/typescript/Carousel/components/InternalContext.d.ts +14 -0
- package/build/typescript/Carousel/components/ItemView.d.ts +7 -0
- package/build/typescript/Carousel/components/RootView.d.ts +16 -0
- package/build/typescript/Carousel/components/ScrollViewGesture.d.ts +12 -0
- package/build/typescript/Carousel/components/index.d.ts +4 -0
- package/build/typescript/Carousel/hooks/index.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useAutoplayController.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useDimensionChangeReaction.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useIndexController.d.ts +10 -0
- package/build/typescript/Carousel/hooks/useItemInterpolation.d.ts +2 -0
- package/build/typescript/Carousel/hooks/useItemVisibilityStore.d.ts +7 -0
- package/build/typescript/Carousel/hooks/useLoopedData.d.ts +1 -0
- package/build/typescript/Carousel/hooks/usePagingAnimation.d.ts +18 -0
- package/build/typescript/Carousel/index.d.ts +3 -1
- package/build/typescript/Carousel/types.d.ts +57 -0
- package/build/typescript/ViewPager/PageStateContext.d.ts +7 -0
- package/build/typescript/ViewPager/ViewPagerNative.d.ts +1 -1
- package/build/typescript/ViewPager/ViewPagerProps.d.ts +11 -0
- package/build/typescript/ViewPager/ViewPagerWeb.d.ts +1 -1
- package/build/typescript/ViewPager/index.d.ts +1 -0
- package/build/typescript/ViewPager/index.native.d.ts +1 -0
- package/build/typescript/ViewPager/utils.d.ts +1 -0
- package/build/typescript/ViewabilityTrackerView/Viewability.d.ts +3 -0
- package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerView.d.ts +2 -0
- package/build/typescript/ViewabilityTrackerView/ViewabilityTrackerViewProps.d.ts +22 -0
- package/build/typescript/ViewabilityTrackerView/index.d.ts +2 -0
- package/build/typescript/ViewabilityTrackerView/measureViewability.d.ts +11 -0
- package/build/typescript/ViewabilityTrackerView/useViewabilityTracker.d.ts +11 -0
- package/build/typescript/hooks/index.d.ts +2 -0
- package/build/typescript/hooks/useDeferredExecutor.d.ts +11 -0
- package/build/typescript/hooks/useIsMounted.d.ts +4 -0
- package/build/typescript/index.d.ts +2 -0
- package/package.json +4 -19
- package/src/Carousel/Carousel.tsx +151 -0
- package/src/Carousel/CarouselProps.ts +34 -53
- package/src/Carousel/animation/animationUtils.ts +1 -0
- package/src/Carousel/animation/createDefaultItemStyle.ts +3 -0
- package/src/Carousel/animation/createDefaultScrollAnimation.ts +13 -0
- package/src/Carousel/animation/index.ts +4 -0
- package/src/Carousel/animation/normalItemStyleFactory.ts +19 -0
- package/src/Carousel/animation/parallaxItemStyleFactory.ts +79 -0
- package/src/Carousel/components/InternalContext.ts +33 -0
- package/src/Carousel/components/ItemView.tsx +56 -0
- package/src/Carousel/components/RootView.tsx +66 -0
- package/src/Carousel/components/ScrollViewGesture.tsx +80 -0
- package/src/Carousel/components/index.ts +4 -0
- package/src/Carousel/hooks/index.ts +7 -0
- package/src/Carousel/hooks/useAutoplayController.ts +54 -0
- package/src/Carousel/hooks/useDimensionChangeReaction.ts +25 -0
- package/src/Carousel/hooks/useIndexController.tsx +76 -0
- package/src/Carousel/hooks/useItemInterpolation.ts +107 -0
- package/src/Carousel/hooks/useItemVisibilityStore.ts +107 -0
- package/src/Carousel/hooks/useLoopedData.ts +26 -0
- package/src/Carousel/hooks/usePagingAnimation.ts +148 -0
- package/src/Carousel/index.ts +4 -2
- package/src/Carousel/types.ts +67 -0
- package/src/ViewPager/ChildrenMemoizedPage.tsx +48 -43
- package/src/ViewPager/PageStateContext.ts +15 -0
- package/src/ViewPager/ViewPagerNative.tsx +35 -11
- package/src/ViewPager/ViewPagerProps.ts +13 -0
- package/src/ViewPager/ViewPagerWeb.tsx +9 -5
- package/src/ViewPager/index.native.ts +1 -0
- package/src/ViewPager/index.ts +1 -0
- package/src/ViewPager/utils.tsx +2 -1
- package/src/ViewabilityTrackerView/Viewability.ts +3 -0
- package/src/ViewabilityTrackerView/ViewabilityTrackerView.tsx +33 -0
- package/src/ViewabilityTrackerView/ViewabilityTrackerViewProps.ts +25 -0
- package/src/ViewabilityTrackerView/index.ts +2 -0
- package/src/ViewabilityTrackerView/measureViewability.ts +56 -0
- package/src/ViewabilityTrackerView/useViewabilityTracker.ts +85 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useDeferredExecutor.ts +46 -0
- package/src/hooks/useIsMounted.ts +19 -0
- package/src/index.ts +3 -0
- package/build/commonjs/Carousel/CarouselNative.js +0 -72
- package/build/commonjs/Carousel/CarouselNative.js.map +0 -1
- package/build/commonjs/Carousel/CarouselWeb.js +0 -237
- package/build/commonjs/Carousel/CarouselWeb.js.map +0 -1
- package/build/commonjs/Carousel/index.native.js.map +0 -1
- package/build/commonjs/Carousel/utils.js +0 -19
- package/build/commonjs/Carousel/utils.js.map +0 -1
- package/build/module/Carousel/CarouselNative.js +0 -54
- package/build/module/Carousel/CarouselNative.js.map +0 -1
- package/build/module/Carousel/CarouselWeb.js +0 -215
- package/build/module/Carousel/CarouselWeb.js.map +0 -1
- package/build/module/Carousel/index.native.js +0 -2
- package/build/module/Carousel/index.native.js.map +0 -1
- package/build/module/Carousel/utils.js +0 -7
- package/build/module/Carousel/utils.js.map +0 -1
- package/build/typescript/Carousel/CarouselNative.d.ts +0 -2
- package/build/typescript/Carousel/CarouselWeb.d.ts +0 -4
- package/build/typescript/Carousel/index.native.d.ts +0 -1
- package/build/typescript/Carousel/utils.d.ts +0 -6
- package/src/Carousel/CarouselNative.tsx +0 -67
- package/src/Carousel/CarouselWeb.tsx +0 -222
- package/src/Carousel/index.native.ts +0 -1
- package/src/Carousel/utils.ts +0 -11
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.defaultPageComponent = exports.defaultLoading = exports.defaultInitialPage = void 0;
|
|
6
|
+
exports.defaultPageComponent = exports.defaultOffscreenPageRerenderLimit = exports.defaultLoading = exports.defaultInitialPage = void 0;
|
|
7
7
|
|
|
8
8
|
var _ChildrenMemoizedPage = _interopRequireDefault(require("./ChildrenMemoizedPage"));
|
|
9
9
|
|
|
@@ -13,6 +13,8 @@ const defaultInitialPage = 0;
|
|
|
13
13
|
exports.defaultInitialPage = defaultInitialPage;
|
|
14
14
|
const defaultLoading = 'lazy';
|
|
15
15
|
exports.defaultLoading = defaultLoading;
|
|
16
|
+
const defaultOffscreenPageRerenderLimit = 0;
|
|
17
|
+
exports.defaultOffscreenPageRerenderLimit = defaultOffscreenPageRerenderLimit;
|
|
16
18
|
const defaultPageComponent = _ChildrenMemoizedPage.default;
|
|
17
19
|
exports.defaultPageComponent = defaultPageComponent;
|
|
18
20
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultInitialPage","defaultLoading","defaultPageComponent","ChildrenMemoizedPage"],"sources":["utils.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"names":["defaultInitialPage","defaultLoading","defaultOffscreenPageRerenderLimit","defaultPageComponent","ChildrenMemoizedPage"],"sources":["utils.tsx"],"sourcesContent":["import { Loading, PageComponent } from './ViewPagerProps';\nimport ChildrenMemoizedPage from './ChildrenMemoizedPage';\n\nexport const defaultInitialPage: number = 0;\n\nexport const defaultLoading: Loading = 'lazy';\n\nexport const defaultOffscreenPageRerenderLimit: number = 0;\n\nexport const defaultPageComponent: PageComponent = ChildrenMemoizedPage;\n"],"mappings":";;;;;;;AACA;;;;AAEO,MAAMA,kBAA0B,GAAG,CAAnC;;AAEA,MAAMC,cAAuB,GAAG,MAAhC;;AAEA,MAAMC,iCAAyC,GAAG,CAAlD;;AAEA,MAAMC,oBAAmC,GAAGC,6BAA5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["Viewability.ts"],"sourcesContent":["export default interface Viewability {\n visible: boolean;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ViewabilityTrackerView;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _useViewabilityTracker = _interopRequireDefault(require("./useViewabilityTracker"));
|
|
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
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
+
|
|
22
|
+
function ViewabilityTrackerView(props) {
|
|
23
|
+
const {
|
|
24
|
+
enabled = true,
|
|
25
|
+
measurementIntervalMillis = 1000,
|
|
26
|
+
onViewabilityChange,
|
|
27
|
+
visiblePercentThreshold = 50,
|
|
28
|
+
...otherProps
|
|
29
|
+
} = props;
|
|
30
|
+
const viewRef = (0, _react.useRef)(null);
|
|
31
|
+
(0, _useViewabilityTracker.default)({
|
|
32
|
+
enabled,
|
|
33
|
+
measurementIntervalMillis,
|
|
34
|
+
onViewabilityChange,
|
|
35
|
+
viewRef,
|
|
36
|
+
visiblePercentThreshold
|
|
37
|
+
});
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({}, otherProps, {
|
|
39
|
+
ref: viewRef,
|
|
40
|
+
collapsable: false
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
;
|
|
45
|
+
//# sourceMappingURL=ViewabilityTrackerView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ViewabilityTrackerView","props","enabled","measurementIntervalMillis","onViewabilityChange","visiblePercentThreshold","otherProps","viewRef","useRef","useViewabilityTracker"],"sources":["ViewabilityTrackerView.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport { View } from 'react-native';\nimport useViewabilityTracker from './useViewabilityTracker';\nimport type ViewabilityTrackerViewProps from './ViewabilityTrackerViewProps';\n\n\nexport default function ViewabilityTrackerView(props: ViewabilityTrackerViewProps) {\n const {\n enabled = true,\n measurementIntervalMillis = 1000,\n onViewabilityChange,\n visiblePercentThreshold = 50,\n ...otherProps\n } = props;\n\n const viewRef = useRef<View>(null);\n\n useViewabilityTracker({\n enabled,\n measurementIntervalMillis,\n onViewabilityChange,\n viewRef,\n visiblePercentThreshold,\n });\n\n return (\n <View\n {...otherProps}\n ref={viewRef}\n collapsable={false}\n />\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;AAIe,SAASA,sBAAT,CAAgCC,KAAhC,EAAoE;EAC/E,MAAM;IACFC,OAAO,GAAG,IADR;IAEFC,yBAAyB,GAAG,IAF1B;IAGFC,mBAHE;IAIFC,uBAAuB,GAAG,EAJxB;IAKF,GAAGC;EALD,IAMFL,KANJ;EAQA,MAAMM,OAAO,GAAG,IAAAC,aAAA,EAAa,IAAb,CAAhB;EAEA,IAAAC,8BAAA,EAAsB;IAClBP,OADkB;IAElBC,yBAFkB;IAGlBC,mBAHkB;IAIlBG,OAJkB;IAKlBF;EALkB,CAAtB;EAQA,oBACI,6BAAC,iBAAD,eACQC,UADR;IAEI,GAAG,EAAEC,OAFT;IAGI,WAAW,EAAE;EAHjB,GADJ;AAOH;;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["ViewabilityTrackerViewProps.ts"],"sourcesContent":["import type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '@fountain-ui/core';\nimport type Viewability from './Viewability';\n\nexport default interface ViewabilityTrackerViewProps extends OverridableComponentProps<ViewProps, {\n /**\n * @default true\n */\n enabled?: boolean;\n\n /**\n * @default 1000\n */\n measurementIntervalMillis?: number;\n\n /**\n *\n */\n onViewabilityChange?: (viewability: Viewability) => void;\n\n /**\n * @default 50\n */\n visiblePercentThreshold?: number;\n}> {}\n"],"mappings":""}
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
Object.defineProperty(exports, "default", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _ViewabilityTrackerView.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _ViewabilityTrackerView = _interopRequireDefault(require("./ViewabilityTrackerView"));
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
//# sourceMappingURL=index.
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './ViewabilityTrackerView';\nexport type { default as ViewabilityTrackerViewProps } from './ViewabilityTrackerViewProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = measureViewability;
|
|
7
|
+
|
|
8
|
+
const computeRectSize = rect => (rect.bottom - rect.top) * (rect.right - rect.left);
|
|
9
|
+
|
|
10
|
+
const normalizePagePosition = value => value != null && Number.isFinite(value) ? value : Number.MAX_SAFE_INTEGER;
|
|
11
|
+
|
|
12
|
+
const normalizeViewSize = size => Number.isFinite(size) && size > 0 ? size : Number.MAX_SAFE_INTEGER;
|
|
13
|
+
|
|
14
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
15
|
+
|
|
16
|
+
function measureViewability(_ref) {
|
|
17
|
+
let {
|
|
18
|
+
view,
|
|
19
|
+
windowWidth,
|
|
20
|
+
windowHeight,
|
|
21
|
+
onViewabilityDetailMeasured
|
|
22
|
+
} = _ref;
|
|
23
|
+
view.measure((x, y, width, height, pageX, pageY) => {
|
|
24
|
+
const safePageX = normalizePagePosition(pageX);
|
|
25
|
+
const safePageY = normalizePagePosition(pageY);
|
|
26
|
+
const visibleRect = {
|
|
27
|
+
top: clamp(safePageY, 0, windowHeight),
|
|
28
|
+
bottom: clamp(safePageY + height, 0, windowHeight),
|
|
29
|
+
left: clamp(safePageX, 0, windowWidth),
|
|
30
|
+
right: clamp(safePageX + width, 0, windowWidth)
|
|
31
|
+
};
|
|
32
|
+
const visibleRectSize = computeRectSize(visibleRect);
|
|
33
|
+
const viewSize = normalizeViewSize(width * height);
|
|
34
|
+
const visiblePercent = Math.round(visibleRectSize / viewSize * 100);
|
|
35
|
+
onViewabilityDetailMeasured === null || onViewabilityDetailMeasured === void 0 ? void 0 : onViewabilityDetailMeasured({
|
|
36
|
+
visiblePercent
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
;
|
|
42
|
+
//# sourceMappingURL=measureViewability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["computeRectSize","rect","bottom","top","right","left","normalizePagePosition","value","Number","isFinite","MAX_SAFE_INTEGER","normalizeViewSize","size","clamp","min","max","Math","measureViewability","view","windowWidth","windowHeight","onViewabilityDetailMeasured","measure","x","y","width","height","pageX","pageY","safePageX","safePageY","visibleRect","visibleRectSize","viewSize","visiblePercent","round"],"sources":["measureViewability.ts"],"sourcesContent":["import type { View } from 'react-native';\n\ninterface Rect {\n top: number,\n bottom: number;\n left: number;\n right: number;\n}\n\nexport interface ViewabilityDetail {\n visiblePercent: number;\n}\n\nexport interface MeasureViewabilityParameters {\n view: View;\n windowWidth: number;\n windowHeight: number;\n onViewabilityDetailMeasured: (detail: ViewabilityDetail) => void;\n}\n\nconst computeRectSize = (rect: Rect): number =>\n (rect.bottom - rect.top) * (rect.right - rect.left);\n\nconst normalizePagePosition = (value?: number): number =>\n (value != null && Number.isFinite(value)) ? value : Number.MAX_SAFE_INTEGER;\n\nconst normalizeViewSize = (size: number): number =>\n Number.isFinite(size) && size > 0 ? size : Number.MAX_SAFE_INTEGER;\n\nconst clamp = (value: number, min: number, max: number): number =>\n Math.min(Math.max(value, min), max);\n\nexport default function measureViewability({\n view,\n windowWidth,\n windowHeight,\n onViewabilityDetailMeasured,\n}: MeasureViewabilityParameters) {\n view.measure((x, y, width, height, pageX?: number, pageY?: number) => {\n const safePageX = normalizePagePosition(pageX);\n const safePageY = normalizePagePosition(pageY);\n\n const visibleRect: Rect = {\n top: clamp(safePageY, 0, windowHeight),\n bottom: clamp(safePageY + height, 0, windowHeight),\n left: clamp(safePageX, 0, windowWidth),\n right: clamp(safePageX + width, 0, windowWidth),\n };\n\n const visibleRectSize = computeRectSize(visibleRect);\n const viewSize = normalizeViewSize(width * height);\n const visiblePercent = Math.round(visibleRectSize / viewSize * 100);\n\n onViewabilityDetailMeasured?.({ visiblePercent });\n });\n};\n"],"mappings":";;;;;;;AAoBA,MAAMA,eAAe,GAAIC,IAAD,IACpB,CAACA,IAAI,CAACC,MAAL,GAAcD,IAAI,CAACE,GAApB,KAA4BF,IAAI,CAACG,KAAL,GAAaH,IAAI,CAACI,IAA9C,CADJ;;AAGA,MAAMC,qBAAqB,GAAIC,KAAD,IACzBA,KAAK,IAAI,IAAT,IAAiBC,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAAlB,GAA4CA,KAA5C,GAAoDC,MAAM,CAACE,gBAD/D;;AAGA,MAAMC,iBAAiB,GAAIC,IAAD,IACtBJ,MAAM,CAACC,QAAP,CAAgBG,IAAhB,KAAyBA,IAAI,GAAG,CAAhC,GAAoCA,IAApC,GAA2CJ,MAAM,CAACE,gBADtD;;AAGA,MAAMG,KAAK,GAAG,CAACN,KAAD,EAAgBO,GAAhB,EAA6BC,GAA7B,KACVC,IAAI,CAACF,GAAL,CAASE,IAAI,CAACD,GAAL,CAASR,KAAT,EAAgBO,GAAhB,CAAT,EAA+BC,GAA/B,CADJ;;AAGe,SAASE,kBAAT,OAKkB;EAAA,IALU;IACvCC,IADuC;IAEvCC,WAFuC;IAGvCC,YAHuC;IAIvCC;EAJuC,CAKV;EAC7BH,IAAI,CAACI,OAAL,CAAa,CAACC,CAAD,EAAIC,CAAJ,EAAOC,KAAP,EAAcC,MAAd,EAAsBC,KAAtB,EAAsCC,KAAtC,KAAyD;IAClE,MAAMC,SAAS,GAAGvB,qBAAqB,CAACqB,KAAD,CAAvC;IACA,MAAMG,SAAS,GAAGxB,qBAAqB,CAACsB,KAAD,CAAvC;IAEA,MAAMG,WAAiB,GAAG;MACtB5B,GAAG,EAAEU,KAAK,CAACiB,SAAD,EAAY,CAAZ,EAAeV,YAAf,CADY;MAEtBlB,MAAM,EAAEW,KAAK,CAACiB,SAAS,GAAGJ,MAAb,EAAqB,CAArB,EAAwBN,YAAxB,CAFS;MAGtBf,IAAI,EAAEQ,KAAK,CAACgB,SAAD,EAAY,CAAZ,EAAeV,WAAf,CAHW;MAItBf,KAAK,EAAES,KAAK,CAACgB,SAAS,GAAGJ,KAAb,EAAoB,CAApB,EAAuBN,WAAvB;IAJU,CAA1B;IAOA,MAAMa,eAAe,GAAGhC,eAAe,CAAC+B,WAAD,CAAvC;IACA,MAAME,QAAQ,GAAGtB,iBAAiB,CAACc,KAAK,GAAGC,MAAT,CAAlC;IACA,MAAMQ,cAAc,GAAGlB,IAAI,CAACmB,KAAL,CAAWH,eAAe,GAAGC,QAAlB,GAA6B,GAAxC,CAAvB;IAEAZ,2BAA2B,SAA3B,IAAAA,2BAA2B,WAA3B,YAAAA,2BAA2B,CAAG;MAAEa;IAAF,CAAH,CAA3B;EACH,CAhBD;AAiBH;;AAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useViewabilityTracker;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _core = require("@fountain-ui/core");
|
|
11
|
+
|
|
12
|
+
var _hooks = require("../hooks");
|
|
13
|
+
|
|
14
|
+
var _measureViewability = _interopRequireDefault(require("./measureViewability"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
const initialViewability = {
|
|
19
|
+
visible: false
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function useViewabilityTracker(config) {
|
|
23
|
+
const {
|
|
24
|
+
enabled,
|
|
25
|
+
measurementIntervalMillis,
|
|
26
|
+
onViewabilityChange,
|
|
27
|
+
viewRef,
|
|
28
|
+
visiblePercentThreshold
|
|
29
|
+
} = config;
|
|
30
|
+
const viewabilityRef = (0, _react.useRef)(initialViewability);
|
|
31
|
+
const executor = (0, _hooks.useDeferredExecutor)();
|
|
32
|
+
const window = (0, _core.useValidWindowDimensions)();
|
|
33
|
+
|
|
34
|
+
const maybeMeasureRecursive = () => {
|
|
35
|
+
if (!enabled) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const mapViewabilityDetailToViewability = detail => {
|
|
40
|
+
return {
|
|
41
|
+
visible: detail.visiblePercent >= visiblePercentThreshold
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const isViewabilityEquals = (a, b) => {
|
|
46
|
+
return a.visible === b.visible;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const dispatchViewabilityChanged = viewability => {
|
|
50
|
+
executor.execute(() => onViewabilityChange === null || onViewabilityChange === void 0 ? void 0 : onViewabilityChange(viewability));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const onViewabilityDetailMeasured = detail => {
|
|
54
|
+
const nextViewability = mapViewabilityDetailToViewability(detail);
|
|
55
|
+
|
|
56
|
+
if (!isViewabilityEquals(viewabilityRef.current, nextViewability)) {
|
|
57
|
+
viewabilityRef.current = nextViewability;
|
|
58
|
+
dispatchViewabilityChanged(nextViewability);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
maybeMeasureRecursive();
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const maybeMeasure = () => {
|
|
65
|
+
if (viewRef.current) {
|
|
66
|
+
(0, _measureViewability.default)({
|
|
67
|
+
view: viewRef.current,
|
|
68
|
+
windowWidth: window.width,
|
|
69
|
+
windowHeight: window.height,
|
|
70
|
+
onViewabilityDetailMeasured
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
executor.execute(maybeMeasure, measurementIntervalMillis);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
(0, _react.useEffect)(() => {
|
|
79
|
+
if (enabled) {
|
|
80
|
+
maybeMeasureRecursive();
|
|
81
|
+
} else {
|
|
82
|
+
executor.cancel();
|
|
83
|
+
}
|
|
84
|
+
}, [enabled]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
;
|
|
88
|
+
//# sourceMappingURL=useViewabilityTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["initialViewability","visible","useViewabilityTracker","config","enabled","measurementIntervalMillis","onViewabilityChange","viewRef","visiblePercentThreshold","viewabilityRef","useRef","executor","useDeferredExecutor","window","useValidWindowDimensions","maybeMeasureRecursive","mapViewabilityDetailToViewability","detail","visiblePercent","isViewabilityEquals","a","b","dispatchViewabilityChanged","viewability","execute","onViewabilityDetailMeasured","nextViewability","current","maybeMeasure","measureViewability","view","windowWidth","width","windowHeight","height","useEffect","cancel"],"sources":["useViewabilityTracker.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useEffect, useRef } from 'react';\nimport type { View } from 'react-native';\nimport { useValidWindowDimensions } from '@fountain-ui/core';\nimport { useDeferredExecutor } from '../hooks';\nimport type { ViewabilityDetail } from './measureViewability';\nimport measureViewability from './measureViewability';\nimport type Viewability from './Viewability';\n\nexport interface ViewabilityTrackerConfig {\n enabled: boolean;\n measurementIntervalMillis: number;\n onViewabilityChange?: (viewability: Viewability) => void;\n viewRef: RefObject<View>;\n visiblePercentThreshold: number;\n}\n\nconst initialViewability: Readonly<Viewability> = { visible: false };\n\nexport default function useViewabilityTracker(config: ViewabilityTrackerConfig) {\n const {\n enabled,\n measurementIntervalMillis,\n onViewabilityChange,\n viewRef,\n visiblePercentThreshold,\n } = config;\n\n const viewabilityRef = useRef<Viewability>(initialViewability);\n\n const executor = useDeferredExecutor();\n\n const window = useValidWindowDimensions();\n\n const maybeMeasureRecursive = () => {\n if (!enabled) {\n return;\n }\n\n const mapViewabilityDetailToViewability = (detail: ViewabilityDetail): Viewability => {\n return { visible: detail.visiblePercent >= visiblePercentThreshold };\n };\n\n const isViewabilityEquals = (a: Viewability, b: Viewability): boolean => {\n return a.visible === b.visible;\n };\n\n const dispatchViewabilityChanged = (viewability: Viewability) => {\n executor.execute(() => onViewabilityChange?.(viewability));\n };\n\n const onViewabilityDetailMeasured = (detail: ViewabilityDetail) => {\n const nextViewability = mapViewabilityDetailToViewability(detail);\n\n if (!isViewabilityEquals(viewabilityRef.current, nextViewability)) {\n viewabilityRef.current = nextViewability;\n\n dispatchViewabilityChanged(nextViewability);\n }\n\n maybeMeasureRecursive();\n };\n\n const maybeMeasure = () => {\n if (viewRef.current) {\n measureViewability({\n view: viewRef.current,\n windowWidth: window.width,\n windowHeight: window.height,\n onViewabilityDetailMeasured,\n });\n }\n };\n\n executor.execute(maybeMeasure, measurementIntervalMillis);\n };\n\n useEffect(() => {\n if (enabled) {\n maybeMeasureRecursive();\n } else {\n executor.cancel();\n }\n }, [enabled]);\n};\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AAEA;;;;AAWA,MAAMA,kBAAyC,GAAG;EAAEC,OAAO,EAAE;AAAX,CAAlD;;AAEe,SAASC,qBAAT,CAA+BC,MAA/B,EAAiE;EAC5E,MAAM;IACFC,OADE;IAEFC,yBAFE;IAGFC,mBAHE;IAIFC,OAJE;IAKFC;EALE,IAMFL,MANJ;EAQA,MAAMM,cAAc,GAAG,IAAAC,aAAA,EAAoBV,kBAApB,CAAvB;EAEA,MAAMW,QAAQ,GAAG,IAAAC,0BAAA,GAAjB;EAEA,MAAMC,MAAM,GAAG,IAAAC,8BAAA,GAAf;;EAEA,MAAMC,qBAAqB,GAAG,MAAM;IAChC,IAAI,CAACX,OAAL,EAAc;MACV;IACH;;IAED,MAAMY,iCAAiC,GAAIC,MAAD,IAA4C;MAClF,OAAO;QAAEhB,OAAO,EAAEgB,MAAM,CAACC,cAAP,IAAyBV;MAApC,CAAP;IACH,CAFD;;IAIA,MAAMW,mBAAmB,GAAG,CAACC,CAAD,EAAiBC,CAAjB,KAA6C;MACrE,OAAOD,CAAC,CAACnB,OAAF,KAAcoB,CAAC,CAACpB,OAAvB;IACH,CAFD;;IAIA,MAAMqB,0BAA0B,GAAIC,WAAD,IAA8B;MAC7DZ,QAAQ,CAACa,OAAT,CAAiB,MAAMlB,mBAAN,aAAMA,mBAAN,uBAAMA,mBAAmB,CAAGiB,WAAH,CAA1C;IACH,CAFD;;IAIA,MAAME,2BAA2B,GAAIR,MAAD,IAA+B;MAC/D,MAAMS,eAAe,GAAGV,iCAAiC,CAACC,MAAD,CAAzD;;MAEA,IAAI,CAACE,mBAAmB,CAACV,cAAc,CAACkB,OAAhB,EAAyBD,eAAzB,CAAxB,EAAmE;QAC/DjB,cAAc,CAACkB,OAAf,GAAyBD,eAAzB;QAEAJ,0BAA0B,CAACI,eAAD,CAA1B;MACH;;MAEDX,qBAAqB;IACxB,CAVD;;IAYA,MAAMa,YAAY,GAAG,MAAM;MACvB,IAAIrB,OAAO,CAACoB,OAAZ,EAAqB;QACjB,IAAAE,2BAAA,EAAmB;UACfC,IAAI,EAAEvB,OAAO,CAACoB,OADC;UAEfI,WAAW,EAAElB,MAAM,CAACmB,KAFL;UAGfC,YAAY,EAAEpB,MAAM,CAACqB,MAHN;UAIfT;QAJe,CAAnB;MAMH;IACJ,CATD;;IAWAd,QAAQ,CAACa,OAAT,CAAiBI,YAAjB,EAA+BvB,yBAA/B;EACH,CAzCD;;EA2CA,IAAA8B,gBAAA,EAAU,MAAM;IACZ,IAAI/B,OAAJ,EAAa;MACTW,qBAAqB;IACxB,CAFD,MAEO;MACHJ,QAAQ,CAACyB,MAAT;IACH;EACJ,CAND,EAMG,CAAChC,OAAD,CANH;AAOH;;AAAA"}
|
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "useDeferredExecutor", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useDeferredExecutor.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useIsMounted", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _useIsMounted.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
6
18
|
Object.defineProperty(exports, "useUnstableCollapsibleAppBar", {
|
|
7
19
|
enumerable: true,
|
|
8
20
|
get: function () {
|
|
@@ -16,6 +28,10 @@ Object.defineProperty(exports, "useUnstableToggleDisplayStyle", {
|
|
|
16
28
|
}
|
|
17
29
|
});
|
|
18
30
|
|
|
31
|
+
var _useDeferredExecutor = _interopRequireDefault(require("./useDeferredExecutor"));
|
|
32
|
+
|
|
33
|
+
var _useIsMounted = _interopRequireDefault(require("./useIsMounted"));
|
|
34
|
+
|
|
19
35
|
var _useUnstableCollapsibleAppBar = _interopRequireDefault(require("./useUnstableCollapsibleAppBar"));
|
|
20
36
|
|
|
21
37
|
var _useUnstableToggleDisplayStyle = _interopRequireDefault(require("./useUnstableToggleDisplayStyle"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as useUnstableCollapsibleAppBar } from './useUnstableCollapsibleAppBar';\nexport { default as useUnstableToggleDisplayStyle } from './useUnstableToggleDisplayStyle';\n\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default as useDeferredExecutor } from './useDeferredExecutor';\nexport { default as useIsMounted } from './useIsMounted';\nexport { default as useUnstableCollapsibleAppBar } from './useUnstableCollapsibleAppBar';\nexport { default as useUnstableToggleDisplayStyle } from './useUnstableToggleDisplayStyle';\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useDeferredExecutor;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _useIsMounted = _interopRequireDefault(require("./useIsMounted"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function useDeferredExecutor() {
|
|
15
|
+
const isMounted = (0, _useIsMounted.default)();
|
|
16
|
+
const timeoutIdRef = (0, _react.useRef)(null);
|
|
17
|
+
const cancel = (0, _react.useCallback)(() => {
|
|
18
|
+
if (timeoutIdRef.current) {
|
|
19
|
+
clearTimeout(timeoutIdRef.current);
|
|
20
|
+
}
|
|
21
|
+
}, []);
|
|
22
|
+
(0, _react.useEffect)(() => {
|
|
23
|
+
return cancel;
|
|
24
|
+
}, []);
|
|
25
|
+
const execute = (0, _react.useCallback)((runnable, delay) => {
|
|
26
|
+
if (!isMounted()) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
cancel();
|
|
31
|
+
|
|
32
|
+
if (Number.isFinite(delay)) {
|
|
33
|
+
timeoutIdRef.current = setTimeout(() => runnable(), delay);
|
|
34
|
+
} else {
|
|
35
|
+
runnable();
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
return {
|
|
39
|
+
cancel,
|
|
40
|
+
execute
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
;
|
|
45
|
+
//# sourceMappingURL=useDeferredExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useDeferredExecutor","isMounted","useIsMounted","timeoutIdRef","useRef","cancel","useCallback","current","clearTimeout","useEffect","execute","runnable","delay","Number","isFinite","setTimeout"],"sources":["useDeferredExecutor.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\nimport useIsMounted from './useIsMounted';\n\nexport interface Runnable {\n (): void;\n}\n\nexport interface DeferredExecute {\n (runnable: Runnable, delay?: number): void;\n}\n\nexport interface DeferredExecutor {\n cancel: () => void;\n execute: DeferredExecute;\n}\n\nexport default function useDeferredExecutor(): DeferredExecutor {\n const isMounted = useIsMounted();\n const timeoutIdRef = useRef<NodeJS.Timer | null>(null);\n\n const cancel = useCallback(() => {\n if (timeoutIdRef.current) {\n clearTimeout(timeoutIdRef.current);\n }\n }, []);\n\n useEffect(() => {\n return cancel;\n }, []);\n\n const execute = useCallback<DeferredExecute>((runnable, delay) => {\n if (!isMounted()) {\n return;\n }\n\n cancel();\n\n if (Number.isFinite(delay)) {\n timeoutIdRef.current = setTimeout(() => runnable(), delay);\n } else {\n runnable();\n }\n }, []);\n\n return { cancel, execute };\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;;;AAee,SAASA,mBAAT,GAAiD;EAC5D,MAAMC,SAAS,GAAG,IAAAC,qBAAA,GAAlB;EACA,MAAMC,YAAY,GAAG,IAAAC,aAAA,EAA4B,IAA5B,CAArB;EAEA,MAAMC,MAAM,GAAG,IAAAC,kBAAA,EAAY,MAAM;IAC7B,IAAIH,YAAY,CAACI,OAAjB,EAA0B;MACtBC,YAAY,CAACL,YAAY,CAACI,OAAd,CAAZ;IACH;EACJ,CAJc,EAIZ,EAJY,CAAf;EAMA,IAAAE,gBAAA,EAAU,MAAM;IACZ,OAAOJ,MAAP;EACH,CAFD,EAEG,EAFH;EAIA,MAAMK,OAAO,GAAG,IAAAJ,kBAAA,EAA6B,CAACK,QAAD,EAAWC,KAAX,KAAqB;IAC9D,IAAI,CAACX,SAAS,EAAd,EAAkB;MACd;IACH;;IAEDI,MAAM;;IAEN,IAAIQ,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAAJ,EAA4B;MACxBT,YAAY,CAACI,OAAb,GAAuBQ,UAAU,CAAC,MAAMJ,QAAQ,EAAf,EAAmBC,KAAnB,CAAjC;IACH,CAFD,MAEO;MACHD,QAAQ;IACX;EACJ,CAZe,EAYb,EAZa,CAAhB;EAcA,OAAO;IAAEN,MAAF;IAAUK;EAAV,CAAP;AACH;;AAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useIsMounted;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
function useIsMounted() {
|
|
11
|
+
const mountedRef = (0, _react.useRef)(false);
|
|
12
|
+
(0, _react.useEffect)(() => {
|
|
13
|
+
mountedRef.current = true;
|
|
14
|
+
return () => {
|
|
15
|
+
mountedRef.current = false;
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
return (0, _react.useCallback)(() => mountedRef.current, []);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
;
|
|
22
|
+
//# sourceMappingURL=useIsMounted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useIsMounted","mountedRef","useRef","useEffect","current","useCallback"],"sources":["useIsMounted.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nexport interface UseIsMounted {\n (): boolean;\n}\n\nexport default function useIsMounted(): UseIsMounted {\n const mountedRef = useRef<boolean>(false);\n\n useEffect(() => {\n mountedRef.current = true;\n\n return () => {\n mountedRef.current = false;\n };\n }, []);\n\n return useCallback(() => mountedRef.current, []);\n};\n"],"mappings":";;;;;;;AAAA;;AAMe,SAASA,YAAT,GAAsC;EACjD,MAAMC,UAAU,GAAG,IAAAC,aAAA,EAAgB,KAAhB,CAAnB;EAEA,IAAAC,gBAAA,EAAU,MAAM;IACZF,UAAU,CAACG,OAAX,GAAqB,IAArB;IAEA,OAAO,MAAM;MACTH,UAAU,CAACG,OAAX,GAAqB,KAArB;IACH,CAFD;EAGH,CAND,EAMG,EANH;EAQA,OAAO,IAAAC,kBAAA,EAAY,MAAMJ,UAAU,CAACG,OAA7B,EAAsC,EAAtC,CAAP;AACH;;AAAA"}
|
package/build/commonjs/index.js
CHANGED
|
@@ -11,7 +11,8 @@ var _exportNames = {
|
|
|
11
11
|
ViewPager: true,
|
|
12
12
|
ComicViewer: true,
|
|
13
13
|
StatusBarProvider: true,
|
|
14
|
-
useStatusBarContext: true
|
|
14
|
+
useStatusBarContext: true,
|
|
15
|
+
ViewabilityTrackerView: true
|
|
15
16
|
};
|
|
16
17
|
Object.defineProperty(exports, "BottomSheet", {
|
|
17
18
|
enumerable: true,
|
|
@@ -55,6 +56,12 @@ Object.defineProperty(exports, "ViewPager", {
|
|
|
55
56
|
return _ViewPager.default;
|
|
56
57
|
}
|
|
57
58
|
});
|
|
59
|
+
Object.defineProperty(exports, "ViewabilityTrackerView", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function () {
|
|
62
|
+
return _ViewabilityTrackerView.default;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
58
65
|
Object.defineProperty(exports, "useStatusBarContext", {
|
|
59
66
|
enumerable: true,
|
|
60
67
|
get: function () {
|
|
@@ -160,6 +167,20 @@ Object.keys(_StatusBarProvider).forEach(function (key) {
|
|
|
160
167
|
});
|
|
161
168
|
});
|
|
162
169
|
|
|
170
|
+
var _ViewabilityTrackerView = _interopRequireWildcard(require("./ViewabilityTrackerView"));
|
|
171
|
+
|
|
172
|
+
Object.keys(_ViewabilityTrackerView).forEach(function (key) {
|
|
173
|
+
if (key === "default" || key === "__esModule") return;
|
|
174
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
175
|
+
if (key in exports && exports[key] === _ViewabilityTrackerView[key]) return;
|
|
176
|
+
Object.defineProperty(exports, key, {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function () {
|
|
179
|
+
return _ViewabilityTrackerView[key];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
163
184
|
var _hooks = require("./hooks");
|
|
164
185
|
|
|
165
186
|
Object.keys(_hooks).forEach(function (key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"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 ComicViewer } from './ComicViewer';\nexport * from './ComicViewer';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport * from './hooks';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"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 ComicViewer } from './ComicViewer';\nexport * from './ComicViewer';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport { default as ViewabilityTrackerView } from './ViewabilityTrackerView';\nexport * from './ViewabilityTrackerView';\n\nexport * from './hooks';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AACA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import ViewabilityTrackerView from '../ViewabilityTrackerView';
|
|
4
|
+
import { useAutoplayController, useDimensionChangeReaction, useIndexController, useItemVisibilityStore, useLoopedData, usePagingAnimation } from './hooks';
|
|
5
|
+
import { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';
|
|
6
|
+
import { InternalContext, RootView, ScrollViewGesture } from './components';
|
|
7
|
+
const Carousel = /*#__PURE__*/forwardRef(function Carousel(props, ref) {
|
|
8
|
+
const {
|
|
9
|
+
autoplay = false,
|
|
10
|
+
autoplayInterval = 3000,
|
|
11
|
+
createItemStyle = createDefaultItemStyle,
|
|
12
|
+
createScrollAnimation = createDefaultScrollAnimation,
|
|
13
|
+
data: originalData,
|
|
14
|
+
disableSmartAutoplay = false,
|
|
15
|
+
initialIndex = 0,
|
|
16
|
+
itemHeight,
|
|
17
|
+
itemWidth,
|
|
18
|
+
loop = false,
|
|
19
|
+
onIndexChange,
|
|
20
|
+
renderItem,
|
|
21
|
+
scrollEnabled = true,
|
|
22
|
+
style,
|
|
23
|
+
windowSize = 5
|
|
24
|
+
} = props;
|
|
25
|
+
const data = useLoopedData(originalData, loop);
|
|
26
|
+
const initialTx = itemWidth * initialIndex;
|
|
27
|
+
const controlledTx = useRef(new Animated.Value(initialTx)).current;
|
|
28
|
+
const offsetTx = useRef(new Animated.Value(0)).current;
|
|
29
|
+
const {
|
|
30
|
+
currentIndex,
|
|
31
|
+
getCurrentIndex,
|
|
32
|
+
lastIndex,
|
|
33
|
+
monitorElement
|
|
34
|
+
} = useIndexController({
|
|
35
|
+
controlledTx,
|
|
36
|
+
initialIndex,
|
|
37
|
+
itemWidth,
|
|
38
|
+
numberOfOriginalData: originalData.length,
|
|
39
|
+
onIndexChange
|
|
40
|
+
});
|
|
41
|
+
const itemVisibilityStore = useItemVisibilityStore({
|
|
42
|
+
currentIndex,
|
|
43
|
+
numberOfData: data.length,
|
|
44
|
+
windowSize
|
|
45
|
+
});
|
|
46
|
+
const {
|
|
47
|
+
finalizeAnimation,
|
|
48
|
+
globalInterpolation,
|
|
49
|
+
startAnimation
|
|
50
|
+
} = usePagingAnimation({
|
|
51
|
+
controlledTx,
|
|
52
|
+
createScrollAnimation,
|
|
53
|
+
getCurrentIndex,
|
|
54
|
+
itemWidth,
|
|
55
|
+
lastIndex,
|
|
56
|
+
loop,
|
|
57
|
+
numberOfData: data.length,
|
|
58
|
+
offsetTx
|
|
59
|
+
});
|
|
60
|
+
const autoplayController = useAutoplayController({
|
|
61
|
+
enabled: autoplay,
|
|
62
|
+
intervalMillis: autoplayInterval,
|
|
63
|
+
startPagingAnimation: startAnimation
|
|
64
|
+
});
|
|
65
|
+
useDimensionChangeReaction({
|
|
66
|
+
controlledTx,
|
|
67
|
+
currentIndex,
|
|
68
|
+
itemWidth
|
|
69
|
+
});
|
|
70
|
+
useImperativeHandle(ref, () => ({
|
|
71
|
+
next: () => startAnimation('next'),
|
|
72
|
+
prev: () => startAnimation('prev'),
|
|
73
|
+
getCurrentIndex
|
|
74
|
+
}), [startAnimation, getCurrentIndex]);
|
|
75
|
+
const contextValue = useMemo(() => ({
|
|
76
|
+
createItemStyle,
|
|
77
|
+
data,
|
|
78
|
+
globalInterpolation,
|
|
79
|
+
itemHeight,
|
|
80
|
+
itemWidth,
|
|
81
|
+
itemVisibilityStore,
|
|
82
|
+
loop
|
|
83
|
+
}), [createItemStyle, data, globalInterpolation, itemHeight, itemWidth, itemVisibilityStore, loop]);
|
|
84
|
+
return /*#__PURE__*/React.createElement(InternalContext.Provider, {
|
|
85
|
+
value: contextValue
|
|
86
|
+
}, monitorElement, /*#__PURE__*/React.createElement(ViewabilityTrackerView, {
|
|
87
|
+
enabled: autoplay && !disableSmartAutoplay,
|
|
88
|
+
measurementIntervalMillis: Math.max(3000, autoplayInterval),
|
|
89
|
+
onViewabilityChange: _ref => {
|
|
90
|
+
let {
|
|
91
|
+
visible
|
|
92
|
+
} = _ref;
|
|
93
|
+
|
|
94
|
+
if (visible) {
|
|
95
|
+
autoplayController.resume();
|
|
96
|
+
} else {
|
|
97
|
+
autoplayController.pause();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, /*#__PURE__*/React.createElement(ScrollViewGesture, {
|
|
101
|
+
autoplayController: autoplayController,
|
|
102
|
+
finalizeAnimation: finalizeAnimation,
|
|
103
|
+
offsetTx: offsetTx,
|
|
104
|
+
scrollEnabled: scrollEnabled,
|
|
105
|
+
startAnimation: startAnimation
|
|
106
|
+
}, /*#__PURE__*/React.createElement(RootView, {
|
|
107
|
+
data: data,
|
|
108
|
+
itemHeight: itemHeight,
|
|
109
|
+
originalData: originalData,
|
|
110
|
+
renderItem: renderItem,
|
|
111
|
+
style: style
|
|
112
|
+
}))));
|
|
113
|
+
});
|
|
114
|
+
export default /*#__PURE__*/memo(Carousel);
|
|
115
|
+
//# sourceMappingURL=Carousel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","forwardRef","memo","useImperativeHandle","useMemo","useRef","Animated","ViewabilityTrackerView","useAutoplayController","useDimensionChangeReaction","useIndexController","useItemVisibilityStore","useLoopedData","usePagingAnimation","createDefaultItemStyle","createDefaultScrollAnimation","InternalContext","RootView","ScrollViewGesture","Carousel","props","ref","autoplay","autoplayInterval","createItemStyle","createScrollAnimation","data","originalData","disableSmartAutoplay","initialIndex","itemHeight","itemWidth","loop","onIndexChange","renderItem","scrollEnabled","style","windowSize","initialTx","controlledTx","Value","current","offsetTx","currentIndex","getCurrentIndex","lastIndex","monitorElement","numberOfOriginalData","length","itemVisibilityStore","numberOfData","finalizeAnimation","globalInterpolation","startAnimation","autoplayController","enabled","intervalMillis","startPagingAnimation","next","prev","contextValue","Math","max","visible","resume","pause"],"sources":["Carousel.tsx"],"sourcesContent":["import React, { forwardRef, memo, useImperativeHandle, useMemo, useRef } from 'react';\nimport { Animated } from 'react-native';\nimport ViewabilityTrackerView from '../ViewabilityTrackerView';\nimport type CarouselProps from './CarouselProps';\nimport type { CarouselInstance } from './types';\nimport {\n useAutoplayController,\n useDimensionChangeReaction,\n useIndexController,\n useItemVisibilityStore,\n useLoopedData,\n usePagingAnimation,\n} from './hooks';\nimport { createDefaultItemStyle, createDefaultScrollAnimation } from './animation';\nimport { InternalContext, RootView, ScrollViewGesture } from './components';\n\nconst Carousel = forwardRef<CarouselInstance, CarouselProps>(function Carousel(props, ref) {\n const {\n autoplay = false,\n autoplayInterval = 3000,\n createItemStyle = createDefaultItemStyle,\n createScrollAnimation = createDefaultScrollAnimation,\n data: originalData,\n disableSmartAutoplay = false,\n initialIndex = 0,\n itemHeight,\n itemWidth,\n loop = false,\n onIndexChange,\n renderItem,\n scrollEnabled = true,\n style,\n windowSize = 5,\n } = props;\n\n const data = useLoopedData(originalData, loop);\n\n const initialTx = itemWidth * initialIndex;\n const controlledTx = useRef(new Animated.Value(initialTx)).current;\n const offsetTx = useRef(new Animated.Value(0)).current;\n\n const {\n currentIndex,\n getCurrentIndex,\n lastIndex,\n monitorElement,\n } = useIndexController({\n controlledTx,\n initialIndex,\n itemWidth,\n numberOfOriginalData: originalData.length,\n onIndexChange,\n });\n\n const itemVisibilityStore = useItemVisibilityStore({\n currentIndex,\n numberOfData: data.length,\n windowSize,\n });\n\n const {\n finalizeAnimation,\n globalInterpolation,\n startAnimation,\n } = usePagingAnimation({\n controlledTx,\n createScrollAnimation,\n getCurrentIndex,\n itemWidth,\n lastIndex,\n loop,\n numberOfData: data.length,\n offsetTx,\n });\n\n const autoplayController = useAutoplayController({\n enabled: autoplay,\n intervalMillis: autoplayInterval,\n startPagingAnimation: startAnimation,\n });\n\n useDimensionChangeReaction({\n controlledTx,\n currentIndex,\n itemWidth,\n });\n\n useImperativeHandle(\n ref,\n () => ({\n next: () => startAnimation('next'),\n prev: () => startAnimation('prev'),\n getCurrentIndex,\n }),\n [startAnimation, getCurrentIndex],\n );\n\n const contextValue = useMemo(() => ({\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n }), [\n createItemStyle,\n data,\n globalInterpolation,\n itemHeight,\n itemWidth,\n itemVisibilityStore,\n loop,\n ]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n {monitorElement}\n\n <ViewabilityTrackerView\n enabled={autoplay && !disableSmartAutoplay}\n measurementIntervalMillis={Math.max(3000, autoplayInterval)}\n onViewabilityChange={({ visible }) => {\n if (visible) {\n autoplayController.resume();\n } else {\n autoplayController.pause();\n }\n }}\n >\n <ScrollViewGesture\n autoplayController={autoplayController}\n finalizeAnimation={finalizeAnimation}\n offsetTx={offsetTx}\n scrollEnabled={scrollEnabled}\n startAnimation={startAnimation}\n >\n <RootView\n data={data}\n itemHeight={itemHeight}\n originalData={originalData}\n renderItem={renderItem}\n style={style}\n />\n </ScrollViewGesture>\n </ViewabilityTrackerView>\n </InternalContext.Provider>\n );\n});\n\nexport default memo(Carousel);\n"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"names":[],"sources":["CarouselProps.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport type { ComponentProps } from '@fountain-ui/core';\nimport type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, RenderItem } from './types';\n\nexport default interface CarouselProps<ItemT = any> extends ComponentProps<{\n ref?: RefObject<CarouselInstance>;\n\n /**\n * If `true`, enable autoplay.\n * @default false\n */\n autoplay?: boolean;\n\n /**\n * Delay in ms until navigating to the next item.\n * @default 3000\n */\n autoplayInterval?: number;\n\n /**\n * The item style creator function.\n * @default createDefaultItemStyle\n */\n createItemStyle?: CreateItemStyle;\n\n /**\n * The scroll animation creator function.\n * @default createDefaultScrollAnimation\n */\n createScrollAnimation?: CreateScrollAnimation;\n\n /**\n * Data for render items.\n */\n data: ReadonlyArray<ItemT>;\n\n /**\n * If `true`, carousel will detect its own viewability and control autoplay automatically.\n * @default false\n */\n disableSmartAutoplay?: boolean;\n\n /**\n * Index of initial item that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * The item width.\n */\n itemHeight: number;\n\n /**\n * The item width.\n */\n itemWidth: number;\n\n /**\n * Enable infinite loop mode.\n * @default false\n */\n loop?: boolean;\n\n /**\n * Callback fired when an index is changed.\n */\n onIndexChange?: (newIndex: number) => void;\n\n /**\n * Takes an item from data and renders it into the list.\n */\n renderItem: RenderItem<ItemT>;\n\n /**\n * Whether to enable scroll gesture.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * The maximum number of items that can respond to pan gesture events.\n * Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)\n * 0 means all items will respond to pan gesture events.\n * @default 5\n */\n windowSize?: number;\n}> {}\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["itemInterpolationInputRange"],"sources":["animationUtils.ts"],"sourcesContent":["export const itemInterpolationInputRange = [-1, 0, 1];\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAG,CAAC,CAAC,CAAF,EAAK,CAAL,EAAQ,CAAR,CAApC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["normalItemStyleFactory"],"sources":["createDefaultItemStyle.ts"],"sourcesContent":["import normalItemStyleFactory from './normalItemStyleFactory';\n\nexport default normalItemStyleFactory();\n"],"mappings":"AAAA,OAAOA,sBAAP,MAAmC,0BAAnC;AAEA,eAAeA,sBAAsB,EAArC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Animated, Easing } from 'react-native';
|
|
2
|
+
export default function createDefaultScrollAnimation(animatedValue, toValue) {
|
|
3
|
+
return Animated.timing(animatedValue, {
|
|
4
|
+
toValue: toValue,
|
|
5
|
+
duration: 350,
|
|
6
|
+
easing: Easing.bezier(0.25, 1, 0.5, 1),
|
|
7
|
+
useNativeDriver: true
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
;
|
|
11
|
+
//# sourceMappingURL=createDefaultScrollAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Animated","Easing","createDefaultScrollAnimation","animatedValue","toValue","timing","duration","easing","bezier","useNativeDriver"],"sources":["createDefaultScrollAnimation.ts"],"sourcesContent":["import { Animated, Easing } from 'react-native';\n\nexport default function createDefaultScrollAnimation(\n animatedValue: Animated.Value,\n toValue: number,\n): Animated.CompositeAnimation {\n return Animated.timing(animatedValue, {\n toValue: toValue,\n duration: 350,\n easing: Easing.bezier(0.25, 1, 0.5, 1),\n useNativeDriver: true,\n });\n};\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,MAAnB,QAAiC,cAAjC;AAEA,eAAe,SAASC,4BAAT,CACXC,aADW,EAEXC,OAFW,EAGgB;EAC3B,OAAOJ,QAAQ,CAACK,MAAT,CAAgBF,aAAhB,EAA+B;IAClCC,OAAO,EAAEA,OADyB;IAElCE,QAAQ,EAAE,GAFwB;IAGlCC,MAAM,EAAEN,MAAM,CAACO,MAAP,CAAc,IAAd,EAAoB,CAApB,EAAuB,GAAvB,EAA4B,CAA5B,CAH0B;IAIlCC,eAAe,EAAE;EAJiB,CAA/B,CAAP;AAMH;AAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as createDefaultItemStyle } from './createDefaultItemStyle';
|
|
2
|
+
export { default as createDefaultScrollAnimation } from './createDefaultScrollAnimation';
|
|
3
|
+
export { default as normalItemStyleFactory } from './normalItemStyleFactory';
|
|
4
|
+
export { default as parallaxItemStyleFactory } from './parallaxItemStyleFactory';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|