react-native-reanimated-carousel 1.2.0-beta.0 → 1.2.0-beta.1
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.
|
@@ -9,11 +9,12 @@ var _reactNativeReanimated = require("react-native-reanimated");
|
|
|
9
9
|
|
|
10
10
|
function useVisibleRanges(options) {
|
|
11
11
|
const {
|
|
12
|
-
total,
|
|
12
|
+
total = 0,
|
|
13
13
|
viewSize,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
translation,
|
|
15
|
+
windowSize: _windowSize = 0
|
|
16
16
|
} = options;
|
|
17
|
+
const windowSize = total <= _windowSize ? total : _windowSize;
|
|
17
18
|
const ranges = (0, _reactNativeReanimated.useDerivedValue)(() => {
|
|
18
19
|
const positiveCount = Math.round(windowSize / 2);
|
|
19
20
|
const negativeCount = windowSize - positiveCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useVisibleRanges","options","total","viewSize","windowSize","
|
|
1
|
+
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useVisibleRanges","options","total","viewSize","translation","windowSize","_windowSize","ranges","positiveCount","Math","round","negativeCount","curIndex","value","negativeRange","positiveRange"],"mappings":";;;;;;;AACA;;AAOO,SAASA,gBAAT,CAA0BC,OAA1B,EAKY;AACf,QAAM;AACFC,IAAAA,KAAK,GAAG,CADN;AAEFC,IAAAA,QAFE;AAGFC,IAAAA,WAHE;AAIFC,IAAAA,UAAU,EAAEC,WAAW,GAAG;AAJxB,MAKFL,OALJ;AAOA,QAAMI,UAAU,GAAGH,KAAK,IAAII,WAAT,GAAuBJ,KAAvB,GAA+BI,WAAlD;AAEA,QAAMC,MAAM,GAAG,4CAAgB,MAAM;AACjC,UAAMC,aAAa,GAAGC,IAAI,CAACC,KAAL,CAAWL,UAAU,GAAG,CAAxB,CAAtB;AACA,UAAMM,aAAa,GAAGN,UAAU,GAAGG,aAAnC;AACA,QAAII,QAAQ,GAAGH,IAAI,CAACC,KAAL,CAAW,CAACN,WAAW,CAACS,KAAb,GAAqBV,QAAhC,CAAf;AACAS,IAAAA,QAAQ,GAAGA,QAAQ,GAAG,CAAX,GAAgBA,QAAQ,GAAGV,KAAZ,GAAqBA,KAApC,GAA4CU,QAAvD;AACA,UAAME,aAAa,GAAG,CAClB,CAACF,QAAQ,GAAGD,aAAX,GAA2BT,KAA5B,IAAqCA,KADnB,EAElB,CAACU,QAAQ,GAAG,CAAX,GAAeV,KAAhB,IAAyBA,KAFP,CAAtB;AAIA,UAAMa,aAAa,GAAG,CAClB,CAACH,QAAQ,GAAGV,KAAZ,IAAqBA,KADH,EAElB,CAACU,QAAQ,GAAGJ,aAAX,GAA2BN,KAA5B,IAAqCA,KAFnB,CAAtB;;AAIA,QAAIY,aAAa,CAAC,CAAD,CAAb,GAAmBZ,KAAnB,IAA4BY,aAAa,CAAC,CAAD,CAAb,GAAmBA,aAAa,CAAC,CAAD,CAAhE,EAAqE;AACjEA,MAAAA,aAAa,CAAC,CAAD,CAAb,GAAmBZ,KAAK,GAAG,CAA3B;AACAa,MAAAA,aAAa,CAAC,CAAD,CAAb,GAAmB,CAAnB;AACH;;AACD,QAAIA,aAAa,CAAC,CAAD,CAAb,GAAmBA,aAAa,CAAC,CAAD,CAApC,EAAyC;AACrCD,MAAAA,aAAa,CAAC,CAAD,CAAb,GAAmBZ,KAAK,GAAG,CAA3B;AACAa,MAAAA,aAAa,CAAC,CAAD,CAAb,GAAmB,CAAnB;AACH;;AACD,WAAO;AAAED,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,KAAP;AACH,GAtBc,EAsBZ,CAACb,KAAD,EAAQG,UAAR,EAAoBD,WAApB,CAtBY,CAAf;AAwBA,SAAOG,MAAP;AACH","sourcesContent":["import type Animated from 'react-native-reanimated';\nimport { useDerivedValue } from 'react-native-reanimated';\n\nexport type IVisibleRanges = Animated.SharedValue<{\n negativeRange: number[];\n positiveRange: number[];\n}>;\n\nexport function useVisibleRanges(options: {\n total: number;\n viewSize: number;\n windowSize?: number;\n translation: Animated.SharedValue<number>;\n}): IVisibleRanges {\n const {\n total = 0,\n viewSize,\n translation,\n windowSize: _windowSize = 0,\n } = options;\n\n const windowSize = total <= _windowSize ? total : _windowSize;\n\n const ranges = useDerivedValue(() => {\n const positiveCount = Math.round(windowSize / 2);\n const negativeCount = windowSize - positiveCount;\n let curIndex = Math.round(-translation.value / viewSize);\n curIndex = curIndex < 0 ? (curIndex % total) + total : curIndex;\n const negativeRange = [\n (curIndex - negativeCount + total) % total,\n (curIndex - 1 + total) % total,\n ];\n const positiveRange = [\n (curIndex + total) % total,\n (curIndex + positiveCount + total) % total,\n ];\n if (negativeRange[0] < total && negativeRange[0] > negativeRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n if (positiveRange[0] > positiveRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n return { negativeRange, positiveRange };\n }, [total, windowSize, translation]);\n\n return ranges;\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useDerivedValue } from 'react-native-reanimated';
|
|
2
2
|
export function useVisibleRanges(options) {
|
|
3
3
|
const {
|
|
4
|
-
total,
|
|
4
|
+
total = 0,
|
|
5
5
|
viewSize,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
translation,
|
|
7
|
+
windowSize: _windowSize = 0
|
|
8
8
|
} = options;
|
|
9
|
+
const windowSize = total <= _windowSize ? total : _windowSize;
|
|
9
10
|
const ranges = useDerivedValue(() => {
|
|
10
11
|
const positiveCount = Math.round(windowSize / 2);
|
|
11
12
|
const negativeCount = windowSize - positiveCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useDerivedValue","useVisibleRanges","options","total","viewSize","windowSize","
|
|
1
|
+
{"version":3,"sources":["useVisibleRanges.tsx"],"names":["useDerivedValue","useVisibleRanges","options","total","viewSize","translation","windowSize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,MAAAA,aAAa,CAAC,CAAD,CAAb,GAAmB,CAAnB;AACH;;AACD,QAAIA,aAAa,CAAC,CAAD,CAAb,GAAmBA,aAAa,CAAC,CAAD,CAApC,EAAyC;AACrCD,MAAAA,aAAa,CAAC,CAAD,CAAb,GAAmBZ,KAAK,GAAG,CAA3B;AACAa,MAAAA,aAAa,CAAC,CAAD,CAAb,GAAmB,CAAnB;AACH;;AACD,WAAO;AAAED,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,KAAP;AACH,GAtB6B,EAsB3B,CAACb,KAAD,EAAQG,UAAR,EAAoBD,WAApB,CAtB2B,CAA9B;AAwBA,SAAOG,MAAP;AACH","sourcesContent":["import type Animated from 'react-native-reanimated';\nimport { useDerivedValue } from 'react-native-reanimated';\n\nexport type IVisibleRanges = Animated.SharedValue<{\n negativeRange: number[];\n positiveRange: number[];\n}>;\n\nexport function useVisibleRanges(options: {\n total: number;\n viewSize: number;\n windowSize?: number;\n translation: Animated.SharedValue<number>;\n}): IVisibleRanges {\n const {\n total = 0,\n viewSize,\n translation,\n windowSize: _windowSize = 0,\n } = options;\n\n const windowSize = total <= _windowSize ? total : _windowSize;\n\n const ranges = useDerivedValue(() => {\n const positiveCount = Math.round(windowSize / 2);\n const negativeCount = windowSize - positiveCount;\n let curIndex = Math.round(-translation.value / viewSize);\n curIndex = curIndex < 0 ? (curIndex % total) + total : curIndex;\n const negativeRange = [\n (curIndex - negativeCount + total) % total,\n (curIndex - 1 + total) % total,\n ];\n const positiveRange = [\n (curIndex + total) % total,\n (curIndex + positiveCount + total) % total,\n ];\n if (negativeRange[0] < total && negativeRange[0] > negativeRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n if (positiveRange[0] > positiveRange[1]) {\n negativeRange[1] = total - 1;\n positiveRange[0] = 0;\n }\n return { negativeRange, positiveRange };\n }, [total, windowSize, translation]);\n\n return ranges;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-reanimated-carousel",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.1",
|
|
4
4
|
"description": "Simple carousel component.fully implemented using Reanimated 2.Infinitely scrolling, very smooth.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -12,7 +12,14 @@ export function useVisibleRanges(options: {
|
|
|
12
12
|
windowSize?: number;
|
|
13
13
|
translation: Animated.SharedValue<number>;
|
|
14
14
|
}): IVisibleRanges {
|
|
15
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
total = 0,
|
|
17
|
+
viewSize,
|
|
18
|
+
translation,
|
|
19
|
+
windowSize: _windowSize = 0,
|
|
20
|
+
} = options;
|
|
21
|
+
|
|
22
|
+
const windowSize = total <= _windowSize ? total : _windowSize;
|
|
16
23
|
|
|
17
24
|
const ranges = useDerivedValue(() => {
|
|
18
25
|
const positiveCount = Math.round(windowSize / 2);
|