@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["Viewability.ts"],"sourcesContent":["export default interface Viewability {\n visible: boolean;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
|
|
3
|
+
import React, { useRef } from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import useViewabilityTracker from './useViewabilityTracker';
|
|
6
|
+
export default function ViewabilityTrackerView(props) {
|
|
7
|
+
const {
|
|
8
|
+
enabled = true,
|
|
9
|
+
measurementIntervalMillis = 1000,
|
|
10
|
+
onViewabilityChange,
|
|
11
|
+
visiblePercentThreshold = 50,
|
|
12
|
+
...otherProps
|
|
13
|
+
} = props;
|
|
14
|
+
const viewRef = useRef(null);
|
|
15
|
+
useViewabilityTracker({
|
|
16
|
+
enabled,
|
|
17
|
+
measurementIntervalMillis,
|
|
18
|
+
onViewabilityChange,
|
|
19
|
+
viewRef,
|
|
20
|
+
visiblePercentThreshold
|
|
21
|
+
});
|
|
22
|
+
return /*#__PURE__*/React.createElement(View, _extends({}, otherProps, {
|
|
23
|
+
ref: viewRef,
|
|
24
|
+
collapsable: false
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
;
|
|
28
|
+
//# sourceMappingURL=ViewabilityTrackerView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useRef","View","useViewabilityTracker","ViewabilityTrackerView","props","enabled","measurementIntervalMillis","onViewabilityChange","visiblePercentThreshold","otherProps","viewRef"],"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,OAAOA,KAAP,IAAgBC,MAAhB,QAA8B,OAA9B;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,OAAOC,qBAAP,MAAkC,yBAAlC;AAIA,eAAe,SAASC,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,GAAGV,MAAM,CAAO,IAAP,CAAtB;EAEAE,qBAAqB,CAAC;IAClBG,OADkB;IAElBC,yBAFkB;IAGlBC,mBAHkB;IAIlBG,OAJkB;IAKlBF;EALkB,CAAD,CAArB;EAQA,oBACI,oBAAC,IAAD,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":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './ViewabilityTrackerView';\nexport type { default as ViewabilityTrackerViewProps } from './ViewabilityTrackerViewProps';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,0BAAxB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const computeRectSize = rect => (rect.bottom - rect.top) * (rect.right - rect.left);
|
|
2
|
+
|
|
3
|
+
const normalizePagePosition = value => value != null && Number.isFinite(value) ? value : Number.MAX_SAFE_INTEGER;
|
|
4
|
+
|
|
5
|
+
const normalizeViewSize = size => Number.isFinite(size) && size > 0 ? size : Number.MAX_SAFE_INTEGER;
|
|
6
|
+
|
|
7
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
8
|
+
|
|
9
|
+
export default function measureViewability(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
view,
|
|
12
|
+
windowWidth,
|
|
13
|
+
windowHeight,
|
|
14
|
+
onViewabilityDetailMeasured
|
|
15
|
+
} = _ref;
|
|
16
|
+
view.measure((x, y, width, height, pageX, pageY) => {
|
|
17
|
+
const safePageX = normalizePagePosition(pageX);
|
|
18
|
+
const safePageY = normalizePagePosition(pageY);
|
|
19
|
+
const visibleRect = {
|
|
20
|
+
top: clamp(safePageY, 0, windowHeight),
|
|
21
|
+
bottom: clamp(safePageY + height, 0, windowHeight),
|
|
22
|
+
left: clamp(safePageX, 0, windowWidth),
|
|
23
|
+
right: clamp(safePageX + width, 0, windowWidth)
|
|
24
|
+
};
|
|
25
|
+
const visibleRectSize = computeRectSize(visibleRect);
|
|
26
|
+
const viewSize = normalizeViewSize(width * height);
|
|
27
|
+
const visiblePercent = Math.round(visibleRectSize / viewSize * 100);
|
|
28
|
+
onViewabilityDetailMeasured === null || onViewabilityDetailMeasured === void 0 ? void 0 : onViewabilityDetailMeasured({
|
|
29
|
+
visiblePercent
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
;
|
|
34
|
+
//# 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;;AAGA,eAAe,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,73 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useValidWindowDimensions } from '@fountain-ui/core';
|
|
3
|
+
import { useDeferredExecutor } from '../hooks';
|
|
4
|
+
import measureViewability from './measureViewability';
|
|
5
|
+
const initialViewability = {
|
|
6
|
+
visible: false
|
|
7
|
+
};
|
|
8
|
+
export default function useViewabilityTracker(config) {
|
|
9
|
+
const {
|
|
10
|
+
enabled,
|
|
11
|
+
measurementIntervalMillis,
|
|
12
|
+
onViewabilityChange,
|
|
13
|
+
viewRef,
|
|
14
|
+
visiblePercentThreshold
|
|
15
|
+
} = config;
|
|
16
|
+
const viewabilityRef = useRef(initialViewability);
|
|
17
|
+
const executor = useDeferredExecutor();
|
|
18
|
+
const window = useValidWindowDimensions();
|
|
19
|
+
|
|
20
|
+
const maybeMeasureRecursive = () => {
|
|
21
|
+
if (!enabled) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const mapViewabilityDetailToViewability = detail => {
|
|
26
|
+
return {
|
|
27
|
+
visible: detail.visiblePercent >= visiblePercentThreshold
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const isViewabilityEquals = (a, b) => {
|
|
32
|
+
return a.visible === b.visible;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const dispatchViewabilityChanged = viewability => {
|
|
36
|
+
executor.execute(() => onViewabilityChange === null || onViewabilityChange === void 0 ? void 0 : onViewabilityChange(viewability));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const onViewabilityDetailMeasured = detail => {
|
|
40
|
+
const nextViewability = mapViewabilityDetailToViewability(detail);
|
|
41
|
+
|
|
42
|
+
if (!isViewabilityEquals(viewabilityRef.current, nextViewability)) {
|
|
43
|
+
viewabilityRef.current = nextViewability;
|
|
44
|
+
dispatchViewabilityChanged(nextViewability);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
maybeMeasureRecursive();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const maybeMeasure = () => {
|
|
51
|
+
if (viewRef.current) {
|
|
52
|
+
measureViewability({
|
|
53
|
+
view: viewRef.current,
|
|
54
|
+
windowWidth: window.width,
|
|
55
|
+
windowHeight: window.height,
|
|
56
|
+
onViewabilityDetailMeasured
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
executor.execute(maybeMeasure, measurementIntervalMillis);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (enabled) {
|
|
66
|
+
maybeMeasureRecursive();
|
|
67
|
+
} else {
|
|
68
|
+
executor.cancel();
|
|
69
|
+
}
|
|
70
|
+
}, [enabled]);
|
|
71
|
+
}
|
|
72
|
+
;
|
|
73
|
+
//# sourceMappingURL=useViewabilityTracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useValidWindowDimensions","useDeferredExecutor","measureViewability","initialViewability","visible","useViewabilityTracker","config","enabled","measurementIntervalMillis","onViewabilityChange","viewRef","visiblePercentThreshold","viewabilityRef","executor","window","maybeMeasureRecursive","mapViewabilityDetailToViewability","detail","visiblePercent","isViewabilityEquals","a","b","dispatchViewabilityChanged","viewability","execute","onViewabilityDetailMeasured","nextViewability","current","maybeMeasure","view","windowWidth","width","windowHeight","height","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,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AAEA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SAASC,mBAAT,QAAoC,UAApC;AAEA,OAAOC,kBAAP,MAA+B,sBAA/B;AAWA,MAAMC,kBAAyC,GAAG;EAAEC,OAAO,EAAE;AAAX,CAAlD;AAEA,eAAe,SAASC,qBAAT,CAA+BC,MAA/B,EAAiE;EAC5E,MAAM;IACFC,OADE;IAEFC,yBAFE;IAGFC,mBAHE;IAIFC,OAJE;IAKFC;EALE,IAMFL,MANJ;EAQA,MAAMM,cAAc,GAAGb,MAAM,CAAcI,kBAAd,CAA7B;EAEA,MAAMU,QAAQ,GAAGZ,mBAAmB,EAApC;EAEA,MAAMa,MAAM,GAAGd,wBAAwB,EAAvC;;EAEA,MAAMe,qBAAqB,GAAG,MAAM;IAChC,IAAI,CAACR,OAAL,EAAc;MACV;IACH;;IAED,MAAMS,iCAAiC,GAAIC,MAAD,IAA4C;MAClF,OAAO;QAAEb,OAAO,EAAEa,MAAM,CAACC,cAAP,IAAyBP;MAApC,CAAP;IACH,CAFD;;IAIA,MAAMQ,mBAAmB,GAAG,CAACC,CAAD,EAAiBC,CAAjB,KAA6C;MACrE,OAAOD,CAAC,CAAChB,OAAF,KAAciB,CAAC,CAACjB,OAAvB;IACH,CAFD;;IAIA,MAAMkB,0BAA0B,GAAIC,WAAD,IAA8B;MAC7DV,QAAQ,CAACW,OAAT,CAAiB,MAAMf,mBAAN,aAAMA,mBAAN,uBAAMA,mBAAmB,CAAGc,WAAH,CAA1C;IACH,CAFD;;IAIA,MAAME,2BAA2B,GAAIR,MAAD,IAA+B;MAC/D,MAAMS,eAAe,GAAGV,iCAAiC,CAACC,MAAD,CAAzD;;MAEA,IAAI,CAACE,mBAAmB,CAACP,cAAc,CAACe,OAAhB,EAAyBD,eAAzB,CAAxB,EAAmE;QAC/Dd,cAAc,CAACe,OAAf,GAAyBD,eAAzB;QAEAJ,0BAA0B,CAACI,eAAD,CAA1B;MACH;;MAEDX,qBAAqB;IACxB,CAVD;;IAYA,MAAMa,YAAY,GAAG,MAAM;MACvB,IAAIlB,OAAO,CAACiB,OAAZ,EAAqB;QACjBzB,kBAAkB,CAAC;UACf2B,IAAI,EAAEnB,OAAO,CAACiB,OADC;UAEfG,WAAW,EAAEhB,MAAM,CAACiB,KAFL;UAGfC,YAAY,EAAElB,MAAM,CAACmB,MAHN;UAIfR;QAJe,CAAD,CAAlB;MAMH;IACJ,CATD;;IAWAZ,QAAQ,CAACW,OAAT,CAAiBI,YAAjB,EAA+BpB,yBAA/B;EACH,CAzCD;;EA2CAV,SAAS,CAAC,MAAM;IACZ,IAAIS,OAAJ,EAAa;MACTQ,qBAAqB;IACxB,CAFD,MAEO;MACHF,QAAQ,CAACqB,MAAT;IACH;EACJ,CANQ,EAMN,CAAC3B,OAAD,CANM,CAAT;AAOH;AAAA"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { default as useDeferredExecutor } from './useDeferredExecutor';
|
|
2
|
+
export { default as useIsMounted } from './useIsMounted';
|
|
1
3
|
export { default as useUnstableCollapsibleAppBar } from './useUnstableCollapsibleAppBar';
|
|
2
4
|
export { default as useUnstableToggleDisplayStyle } from './useUnstableToggleDisplayStyle';
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","useUnstableCollapsibleAppBar","useUnstableToggleDisplayStyle"],"sources":["index.ts"],"sourcesContent":["export { default as useUnstableCollapsibleAppBar } from './useUnstableCollapsibleAppBar';\nexport { default as useUnstableToggleDisplayStyle } from './useUnstableToggleDisplayStyle';\n\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,4BAApB,QAAwD,gCAAxD;AACA,
|
|
1
|
+
{"version":3,"names":["default","useDeferredExecutor","useIsMounted","useUnstableCollapsibleAppBar","useUnstableToggleDisplayStyle"],"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,SAASA,OAAO,IAAIC,mBAApB,QAA+C,uBAA/C;AACA,SAASD,OAAO,IAAIE,YAApB,QAAwC,gBAAxC;AACA,SAASF,OAAO,IAAIG,4BAApB,QAAwD,gCAAxD;AACA,SAASH,OAAO,IAAII,6BAApB,QAAyD,iCAAzD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import useIsMounted from './useIsMounted';
|
|
3
|
+
export default function useDeferredExecutor() {
|
|
4
|
+
const isMounted = useIsMounted();
|
|
5
|
+
const timeoutIdRef = useRef(null);
|
|
6
|
+
const cancel = useCallback(() => {
|
|
7
|
+
if (timeoutIdRef.current) {
|
|
8
|
+
clearTimeout(timeoutIdRef.current);
|
|
9
|
+
}
|
|
10
|
+
}, []);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
return cancel;
|
|
13
|
+
}, []);
|
|
14
|
+
const execute = useCallback((runnable, delay) => {
|
|
15
|
+
if (!isMounted()) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
cancel();
|
|
20
|
+
|
|
21
|
+
if (Number.isFinite(delay)) {
|
|
22
|
+
timeoutIdRef.current = setTimeout(() => runnable(), delay);
|
|
23
|
+
} else {
|
|
24
|
+
runnable();
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
return {
|
|
28
|
+
cancel,
|
|
29
|
+
execute
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
;
|
|
33
|
+
//# sourceMappingURL=useDeferredExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useIsMounted","useDeferredExecutor","isMounted","timeoutIdRef","cancel","current","clearTimeout","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,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAeA,eAAe,SAASC,mBAAT,GAAiD;EAC5D,MAAMC,SAAS,GAAGF,YAAY,EAA9B;EACA,MAAMG,YAAY,GAAGJ,MAAM,CAAsB,IAAtB,CAA3B;EAEA,MAAMK,MAAM,GAAGP,WAAW,CAAC,MAAM;IAC7B,IAAIM,YAAY,CAACE,OAAjB,EAA0B;MACtBC,YAAY,CAACH,YAAY,CAACE,OAAd,CAAZ;IACH;EACJ,CAJyB,EAIvB,EAJuB,CAA1B;EAMAP,SAAS,CAAC,MAAM;IACZ,OAAOM,MAAP;EACH,CAFQ,EAEN,EAFM,CAAT;EAIA,MAAMG,OAAO,GAAGV,WAAW,CAAkB,CAACW,QAAD,EAAWC,KAAX,KAAqB;IAC9D,IAAI,CAACP,SAAS,EAAd,EAAkB;MACd;IACH;;IAEDE,MAAM;;IAEN,IAAIM,MAAM,CAACC,QAAP,CAAgBF,KAAhB,CAAJ,EAA4B;MACxBN,YAAY,CAACE,OAAb,GAAuBO,UAAU,CAAC,MAAMJ,QAAQ,EAAf,EAAmBC,KAAnB,CAAjC;IACH,CAFD,MAEO;MACHD,QAAQ;IACX;EACJ,CAZ0B,EAYxB,EAZwB,CAA3B;EAcA,OAAO;IAAEJ,MAAF;IAAUG;EAAV,CAAP;AACH;AAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
export default function useIsMounted() {
|
|
3
|
+
const mountedRef = useRef(false);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
mountedRef.current = true;
|
|
6
|
+
return () => {
|
|
7
|
+
mountedRef.current = false;
|
|
8
|
+
};
|
|
9
|
+
}, []);
|
|
10
|
+
return useCallback(() => mountedRef.current, []);
|
|
11
|
+
}
|
|
12
|
+
;
|
|
13
|
+
//# sourceMappingURL=useIsMounted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useRef","useIsMounted","mountedRef","current"],"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,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,QAA+C,OAA/C;AAMA,eAAe,SAASC,YAAT,GAAsC;EACjD,MAAMC,UAAU,GAAGF,MAAM,CAAU,KAAV,CAAzB;EAEAD,SAAS,CAAC,MAAM;IACZG,UAAU,CAACC,OAAX,GAAqB,IAArB;IAEA,OAAO,MAAM;MACTD,UAAU,CAACC,OAAX,GAAqB,KAArB;IACH,CAFD;EAGH,CANQ,EAMN,EANM,CAAT;EAQA,OAAOL,WAAW,CAAC,MAAMI,UAAU,CAACC,OAAlB,EAA2B,EAA3B,CAAlB;AACH;AAAA"}
|
package/build/module/index.js
CHANGED
|
@@ -12,5 +12,7 @@ export { default as ComicViewer } from './ComicViewer';
|
|
|
12
12
|
export * from './ComicViewer';
|
|
13
13
|
export { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';
|
|
14
14
|
export * from './StatusBarProvider';
|
|
15
|
+
export { default as ViewabilityTrackerView } from './ViewabilityTrackerView';
|
|
16
|
+
export * from './ViewabilityTrackerView';
|
|
15
17
|
export * from './hooks';
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","ComicViewer","StatusBarProvider","useStatusBarContext"],"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":"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,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASN,OAAO,IAAIO,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,cAAc,SAAd"}
|
|
1
|
+
{"version":3,"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","ComicViewer","StatusBarProvider","useStatusBarContext","ViewabilityTrackerView"],"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,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,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASN,OAAO,IAAIO,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,SAASR,OAAO,IAAIS,sBAApB,QAAkD,0BAAlD;AACA,cAAc,0BAAd;AAEA,cAAc,SAAd"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type CarouselProps from './CarouselProps';
|
|
3
|
+
import type { CarouselInstance } from './types';
|
|
4
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<CarouselProps<any>, "style" | "data" | "autoplay" | "autoplayInterval" | "createItemStyle" | "createScrollAnimation" | "disableSmartAutoplay" | "initialIndex" | "itemHeight" | "itemWidth" | "loop" | "onIndexChange" | "renderItem" | "scrollEnabled" | "windowSize"> & React.RefAttributes<CarouselInstance>>>;
|
|
5
|
+
export default _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ListRenderItemInfo } from 'react-native';
|
|
1
|
+
import type { RefObject } from 'react';
|
|
3
2
|
import type { ComponentProps } from '@fountain-ui/core';
|
|
3
|
+
import type { CarouselInstance, CreateItemStyle, CreateScrollAnimation, RenderItem } from './types';
|
|
4
4
|
export default interface CarouselProps<ItemT = any> extends ComponentProps<{
|
|
5
|
+
ref?: RefObject<CarouselInstance>;
|
|
5
6
|
/**
|
|
6
7
|
* If `true`, enable autoplay.
|
|
7
8
|
* @default false
|
|
@@ -13,78 +14,61 @@ export default interface CarouselProps<ItemT = any> extends ComponentProps<{
|
|
|
13
14
|
*/
|
|
14
15
|
autoplayInterval?: number;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* The item style creator function.
|
|
18
|
+
* @default createDefaultItemStyle
|
|
17
19
|
*/
|
|
18
|
-
|
|
20
|
+
createItemStyle?: CreateItemStyle;
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
22
|
+
* The scroll animation creator function.
|
|
23
|
+
* @default createDefaultScrollAnimation
|
|
24
|
+
*/
|
|
25
|
+
createScrollAnimation?: CreateScrollAnimation;
|
|
26
|
+
/**
|
|
27
|
+
* Data for render items.
|
|
21
28
|
*/
|
|
22
29
|
data: ReadonlyArray<ItemT>;
|
|
23
30
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @default
|
|
31
|
+
* If `true`, carousel will detect its own viewability and control autoplay automatically.
|
|
32
|
+
* @default false
|
|
26
33
|
*/
|
|
27
|
-
|
|
34
|
+
disableSmartAutoplay?: boolean;
|
|
28
35
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @default 0
|
|
36
|
+
* Index of initial item that should be selected.
|
|
37
|
+
* @default 0
|
|
31
38
|
*/
|
|
32
|
-
|
|
39
|
+
initialIndex?: number;
|
|
33
40
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @default 0.990
|
|
41
|
+
* The item width.
|
|
36
42
|
*/
|
|
37
|
-
|
|
43
|
+
itemHeight: number;
|
|
38
44
|
/**
|
|
39
|
-
*
|
|
45
|
+
* The item width.
|
|
40
46
|
*/
|
|
41
|
-
|
|
47
|
+
itemWidth: number;
|
|
42
48
|
/**
|
|
43
49
|
* Enable infinite loop mode.
|
|
44
50
|
* @default false
|
|
45
51
|
*/
|
|
46
|
-
|
|
52
|
+
loop?: boolean;
|
|
47
53
|
/**
|
|
48
54
|
* Callback fired when an index is changed.
|
|
49
55
|
*/
|
|
50
|
-
|
|
56
|
+
onIndexChange?: (newIndex: number) => void;
|
|
51
57
|
/**
|
|
52
58
|
* Takes an item from data and renders it into the list.
|
|
53
59
|
*/
|
|
54
|
-
renderItem:
|
|
55
|
-
/**
|
|
56
|
-
* Web only. Number of slides to scroll at once.
|
|
57
|
-
* @default 1
|
|
58
|
-
*/
|
|
59
|
-
slidesToScroll?: number;
|
|
60
|
-
/**
|
|
61
|
-
* Web only. Number of slides to display.
|
|
62
|
-
* @default 1
|
|
63
|
-
*/
|
|
64
|
-
slidesToShow?: number;
|
|
60
|
+
renderItem: RenderItem<ItemT>;
|
|
65
61
|
/**
|
|
66
|
-
*
|
|
62
|
+
* Whether to enable scroll gesture.
|
|
67
63
|
* @default true
|
|
68
64
|
*/
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Web only. Enable arrows to display.
|
|
72
|
-
* @default true
|
|
73
|
-
*/
|
|
74
|
-
arrows?: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Web only. Style of arrows
|
|
77
|
-
* @default true
|
|
78
|
-
*/
|
|
79
|
-
arrowsStyle?: object;
|
|
80
|
-
/**
|
|
81
|
-
* Web only. Style of track
|
|
82
|
-
* @default object
|
|
83
|
-
*/
|
|
84
|
-
trackStyle?: object;
|
|
65
|
+
scrollEnabled?: boolean;
|
|
85
66
|
/**
|
|
86
|
-
*
|
|
67
|
+
* The maximum number of items that can respond to pan gesture events.
|
|
68
|
+
* Due to the nature of the `active` item, it accepts only odd number. (e.g. 1, 3, 5...)
|
|
69
|
+
* 0 means all items will respond to pan gesture events.
|
|
70
|
+
* @default 5
|
|
87
71
|
*/
|
|
88
|
-
|
|
72
|
+
windowSize?: number;
|
|
89
73
|
}> {
|
|
90
74
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const itemInterpolationInputRange: number[];
|
|
@@ -0,0 +1,4 @@
|
|
|
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';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CreateItemStyle } from '../types';
|
|
2
|
+
export interface ParallaxAnimationConfig {
|
|
3
|
+
parallaxActiveItemScale?: number;
|
|
4
|
+
parallaxActiveItemOpacity?: number;
|
|
5
|
+
parallaxAdjacentItemScale?: number;
|
|
6
|
+
parallaxAdjacentItemOpacity?: number;
|
|
7
|
+
parallaxScrollingOffset?: number;
|
|
8
|
+
}
|
|
9
|
+
export default function parallaxItemStyleFactory(config?: ParallaxAnimationConfig): CreateItemStyle;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import type { CreateItemStyle, ItemVisibilityStore } from '../types';
|
|
4
|
+
export interface InternalContextValue<ItemT> {
|
|
5
|
+
createItemStyle: CreateItemStyle;
|
|
6
|
+
data: ReadonlyArray<ItemT>;
|
|
7
|
+
globalInterpolation: Animated.AnimatedInterpolation;
|
|
8
|
+
itemHeight: number;
|
|
9
|
+
itemWidth: number;
|
|
10
|
+
itemVisibilityStore: ItemVisibilityStore;
|
|
11
|
+
loop: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const InternalContext: import("react").Context<InternalContextValue<any>>;
|
|
14
|
+
export default InternalContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
export interface ItemViewProps {
|
|
4
|
+
children: (interpolation: Animated.AnimatedInterpolation) => ReactElement | null;
|
|
5
|
+
index: number;
|
|
6
|
+
}
|
|
7
|
+
export default function ItemView(props: ItemViewProps): JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ViewProps, View } from 'react-native';
|
|
3
|
+
import type { RenderItem } from '../types';
|
|
4
|
+
export declare type RootViewProps<ItemT> = ViewProps & {
|
|
5
|
+
data: ReadonlyArray<ItemT>;
|
|
6
|
+
itemHeight: number;
|
|
7
|
+
originalData: ReadonlyArray<ItemT>;
|
|
8
|
+
renderItem: RenderItem<ItemT>;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ViewProps & {
|
|
11
|
+
data: readonly any[];
|
|
12
|
+
itemHeight: number;
|
|
13
|
+
originalData: readonly any[];
|
|
14
|
+
renderItem: RenderItem<any>;
|
|
15
|
+
} & React.RefAttributes<View>>>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import type { AutoplayController, StartPagingAnimation } from '../types';
|
|
4
|
+
export interface ScrollViewGestureProps {
|
|
5
|
+
autoplayController: AutoplayController;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
finalizeAnimation: () => void;
|
|
8
|
+
offsetTx: Animated.Value;
|
|
9
|
+
scrollEnabled: boolean;
|
|
10
|
+
startAnimation: StartPagingAnimation;
|
|
11
|
+
}
|
|
12
|
+
export default function ScrollViewGesture(props: ScrollViewGestureProps): JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as useAutoplayController } from './useAutoplayController';
|
|
2
|
+
export { default as useDimensionChangeReaction } from './useDimensionChangeReaction';
|
|
3
|
+
export { default as useIndexController } from './useIndexController';
|
|
4
|
+
export { default as useItemInterpolation } from './useItemInterpolation';
|
|
5
|
+
export { default as useLoopedData } from './useLoopedData';
|
|
6
|
+
export { default as usePagingAnimation } from './usePagingAnimation';
|
|
7
|
+
export { default as useItemVisibilityStore } from './useItemVisibilityStore';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AutoplayController, StartPagingAnimation } from '../types';
|
|
2
|
+
export interface AutoplayConfig {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
intervalMillis: number;
|
|
5
|
+
startPagingAnimation: StartPagingAnimation;
|
|
6
|
+
}
|
|
7
|
+
export default function useAutoplayController(config: AutoplayConfig): AutoplayController;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
import type { IndexController } from '../types';
|
|
3
|
+
export interface UseIndexControllerParameters {
|
|
4
|
+
controlledTx: Animated.AnimatedValue;
|
|
5
|
+
initialIndex: number;
|
|
6
|
+
itemWidth: number;
|
|
7
|
+
numberOfOriginalData: number;
|
|
8
|
+
onIndexChange?: (newIndex: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export default function useIndexController(params: UseIndexControllerParameters): IndexController;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useLoopedData<ItemT>(originalData: ReadonlyArray<ItemT>, loop: boolean): ReadonlyArray<ItemT>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
import type { CreateScrollAnimation, GetCurrentIndex, StartPagingAnimation } from '../types';
|
|
3
|
+
export interface PagingAnimationConfig {
|
|
4
|
+
controlledTx: Animated.Value;
|
|
5
|
+
createScrollAnimation: CreateScrollAnimation;
|
|
6
|
+
getCurrentIndex: GetCurrentIndex;
|
|
7
|
+
itemWidth: number;
|
|
8
|
+
lastIndex: number;
|
|
9
|
+
loop: boolean;
|
|
10
|
+
numberOfData: number;
|
|
11
|
+
offsetTx: Animated.Value;
|
|
12
|
+
}
|
|
13
|
+
export interface UsePagingAnimation {
|
|
14
|
+
finalizeAnimation: () => void;
|
|
15
|
+
globalInterpolation: Animated.AnimatedInterpolation;
|
|
16
|
+
startAnimation: StartPagingAnimation;
|
|
17
|
+
}
|
|
18
|
+
export default function usePagingAnimation(config: PagingAnimationConfig): UsePagingAnimation;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { default } from './
|
|
1
|
+
export { default } from './Carousel';
|
|
2
2
|
export type { default as CarouselProps } from './CarouselProps';
|
|
3
|
+
export type { CarouselInstance } from './types';
|
|
4
|
+
export { normalItemStyleFactory, parallaxItemStyleFactory } from './animation';
|