@r0b0t3d/react-native-carousel 3.4.6 → 3.4.8

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.
Files changed (64) hide show
  1. package/lib/commonjs/components/Carousel.js +290 -195
  2. package/lib/commonjs/components/Carousel.js.map +1 -1
  3. package/lib/commonjs/components/CarouselContainer.js +17 -31
  4. package/lib/commonjs/components/CarouselContainer.js.map +1 -1
  5. package/lib/commonjs/components/PageItem.js +52 -45
  6. package/lib/commonjs/components/PageItem.js.map +1 -1
  7. package/lib/commonjs/components/PaginationIndicator.js +23 -34
  8. package/lib/commonjs/components/PaginationIndicator.js.map +1 -1
  9. package/lib/commonjs/components/useCarouselContext.js +3 -8
  10. package/lib/commonjs/components/useCarouselContext.js.map +1 -1
  11. package/lib/commonjs/components/useInternalCarouselContext.js +3 -6
  12. package/lib/commonjs/components/useInternalCarouselContext.js.map +1 -1
  13. package/lib/commonjs/index.js +7 -17
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/package.json +1 -0
  16. package/lib/commonjs/types.js +4 -0
  17. package/lib/commonjs/types.js.map +1 -1
  18. package/lib/commonjs/utils.js +24 -18
  19. package/lib/commonjs/utils.js.map +1 -1
  20. package/lib/module/components/Carousel.js +291 -180
  21. package/lib/module/components/Carousel.js.map +1 -1
  22. package/lib/module/components/CarouselContainer.js +18 -23
  23. package/lib/module/components/CarouselContainer.js.map +1 -1
  24. package/lib/module/components/PageItem.js +53 -37
  25. package/lib/module/components/PageItem.js.map +1 -1
  26. package/lib/module/components/PaginationIndicator.js +23 -24
  27. package/lib/module/components/PaginationIndicator.js.map +1 -1
  28. package/lib/module/components/useCarouselContext.js +2 -2
  29. package/lib/module/components/useCarouselContext.js.map +1 -1
  30. package/lib/module/components/useInternalCarouselContext.js +2 -0
  31. package/lib/module/components/useInternalCarouselContext.js.map +1 -1
  32. package/lib/module/index.js +2 -0
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/module/types.js +2 -0
  35. package/lib/module/types.js.map +1 -1
  36. package/lib/module/utils.js +22 -12
  37. package/lib/module/utils.js.map +1 -1
  38. package/lib/typescript/components/Carousel.d.ts +3 -1
  39. package/lib/typescript/components/Carousel.d.ts.map +1 -0
  40. package/lib/typescript/components/CarouselContainer.d.ts +3 -2
  41. package/lib/typescript/components/CarouselContainer.d.ts.map +1 -0
  42. package/lib/typescript/components/PageItem.d.ts +5 -3
  43. package/lib/typescript/components/PageItem.d.ts.map +1 -0
  44. package/lib/typescript/components/PaginationIndicator.d.ts +3 -1
  45. package/lib/typescript/components/PaginationIndicator.d.ts.map +1 -0
  46. package/lib/typescript/components/useCarouselContext.d.ts +1 -1
  47. package/lib/typescript/components/useCarouselContext.d.ts.map +1 -0
  48. package/lib/typescript/components/useInternalCarouselContext.d.ts +1 -1
  49. package/lib/typescript/components/useInternalCarouselContext.d.ts.map +1 -0
  50. package/lib/typescript/index.d.ts +1 -0
  51. package/lib/typescript/index.d.ts.map +1 -0
  52. package/lib/typescript/types.d.ts +17 -15
  53. package/lib/typescript/types.d.ts.map +1 -0
  54. package/lib/typescript/utils.d.ts +4 -1
  55. package/lib/typescript/utils.d.ts.map +1 -0
  56. package/package.json +26 -29
  57. package/src/components/Carousel.tsx +407 -206
  58. package/src/components/CarouselContainer.tsx +4 -4
  59. package/src/components/PageItem.tsx +55 -33
  60. package/src/components/PaginationIndicator.tsx +2 -2
  61. package/src/components/useCarouselContext.ts +0 -1
  62. package/src/components/useInternalCarouselContext.ts +0 -1
  63. package/src/types.ts +9 -7
  64. package/src/utils.ts +31 -11
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+
1
3
  export const generateOffsets = ({
2
4
  sliderWidth,
3
5
  itemWidth,
@@ -6,7 +8,6 @@ export const generateOffsets = ({
6
8
  }) => {
7
9
  const padding = (sliderWidth - itemWidth) / 2;
8
10
  const result = [];
9
-
10
11
  for (let i = 0; i < itemCount; i++) {
11
12
  if (i === 0) {
12
13
  result.push(0);
@@ -16,32 +17,41 @@ export const generateOffsets = ({
16
17
  result.push(i * itemWidth + horizontalPadding - padding);
17
18
  }
18
19
  }
19
-
20
20
  return result;
21
21
  };
22
- export const findNearestPage = (offset, offsets, delta) => {
22
+ export const findNearestPage = (offset, offsets) => {
23
23
  'worklet';
24
24
 
25
- let mid;
26
25
  let lo = 0;
27
26
  let hi = offsets.length - 1;
28
-
29
27
  while (hi - lo > 1) {
30
- mid = Math.floor((lo + hi) / 2);
31
-
28
+ const mid = Math.floor((lo + hi) / 2);
32
29
  if (offsets[mid] < offset) {
33
30
  lo = mid;
34
31
  } else {
35
32
  hi = mid;
36
33
  }
37
34
  }
35
+ return offset - offsets[lo] <= offsets[hi] - offset ? lo : hi;
36
+ };
37
+ export function getLogicalPage(renderIndex, totalItems, additionalPagesPerSide, loop) {
38
+ 'worklet';
38
39
 
39
- const nearestPage = offset - offsets[lo] <= offsets[hi] - offset ? lo : hi;
40
-
41
- if (Math.abs(offsets[nearestPage] - offset) < delta) {
42
- return nearestPage;
40
+ if (!loop) {
41
+ return renderIndex;
43
42
  }
43
+ return (renderIndex - additionalPagesPerSide + totalItems) % totalItems;
44
+ }
45
+ export function getLoopBoundaryTarget(renderPage, totalPages, additionalPagesPerSide) {
46
+ 'worklet';
44
47
 
48
+ const totalRenderPages = totalPages + additionalPagesPerSide * 2;
49
+ if (renderPage <= 0) {
50
+ return totalPages;
51
+ }
52
+ if (renderPage >= totalRenderPages - 1) {
53
+ return renderPage - totalPages;
54
+ }
45
55
  return -1;
46
- };
56
+ }
47
57
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":["generateOffsets","sliderWidth","itemWidth","itemCount","horizontalPadding","padding","result","i","push","findNearestPage","offset","offsets","delta","mid","lo","hi","length","Math","floor","nearestPage","abs"],"mappings":"AAAA,OAAO,MAAMA,eAAe,GAAG,CAAC;AAC9BC,EAAAA,WAD8B;AAE9BC,EAAAA,SAF8B;AAG9BC,EAAAA,SA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CAAP,GAAcL,MAAtC,GAA+CI,EAA/C,GAAoDC,EAAxE;;AACA,MAAIE,IAAI,CAACG,GAAL,CAAST,OAAO,CAACQ,WAAD,CAAP,GAAuBT,MAAhC,IAA0CE,KAA9C,EAAqD;AACnD,WAAOO,WAAP;AACD;;AACD,SAAO,CAAC,CAAR;AACD,CAtBM","sourcesContent":["export const generateOffsets = ({\n sliderWidth,\n itemWidth,\n itemCount,\n horizontalPadding,\n}: {\n sliderWidth: number;\n itemWidth: number;\n itemCount: number;\n horizontalPadding: number;\n}) => {\n const padding = (sliderWidth - itemWidth) / 2;\n const result: number[] = [];\n for (let i = 0; i < itemCount; i++) {\n if (i === 0) {\n result.push(0);\n } else if (i === itemCount - 1) {\n result.push(i * itemWidth + 2 * (horizontalPadding - padding));\n } else {\n result.push(i * itemWidth + horizontalPadding - padding);\n }\n }\n return result;\n};\n\nexport const findNearestPage = (\n offset: number,\n offsets: number[],\n delta: number\n) => {\n 'worklet';\n let mid;\n let lo = 0;\n let hi = offsets.length - 1;\n while (hi - lo > 1) {\n mid = Math.floor((lo + hi) / 2);\n if (offsets[mid] < offset) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n const nearestPage = offset - offsets[lo] <= offsets[hi] - offset ? lo : hi;\n if (Math.abs(offsets[nearestPage] - offset) < delta) {\n return nearestPage;\n }\n return -1;\n};\n"]}
1
+ {"version":3,"names":["generateOffsets","sliderWidth","itemWidth","itemCount","horizontalPadding","padding","result","i","push","findNearestPage","offset","offsets","lo","hi","length","mid","Math","floor","getLogicalPage","renderIndex","totalItems","additionalPagesPerSide","loop","getLoopBoundaryTarget","renderPage","totalPages","totalRenderPages"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA,OAAO,MAAMA,eAAe,GAAGA,CAAC;EAC9BC,WAAW;EACXC,SAAS;EACTC,SAAS;EACTC;AAMF,CAAC,KAAK;EACJ,MAAMC,OAAO,GAAG,CAACJ,WAAW,GAAGC,SAAS,IAAI,CAAC;EAC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AW;EACpB;EACA,OAAO,CAACA,WAAW,GAAGE,sBAAsB,GAAGD,UAAU,IAAIA,UAAU;AACzE;AAEA,OAAO,SAASG,qBAAqBA,CACnCC,UAAkB,EAClBC,UAAkB,EAClBJ,sBAA8B,EACtB;EACR,SAAS;;EACT,MAAMK,gBAAgB,GAAGD,UAAU,GAAGJ,sBAAsB,GAAG,CAAC;EAChE,IAAIG,UAAU,IAAI,CAAC,EAAE;IACnB,OAAOC,UAAU;EACnB;EACA,IAAID,UAAU,IAAIE,gBAAgB,GAAG,CAAC,EAAE;IACtC,OAAOF,UAAU,GAAGC,UAAU;EAChC;EACA,OAAO,CAAC,CAAC;AACX","ignoreList":[]}
@@ -1,3 +1,5 @@
1
+ import React from 'react';
1
2
  import type { CarouselProps } from '../types';
2
- declare function Carousel<TData>({ style, data, initialPage, loop, additionalPagesPerSide, autoPlay, duration, animation, sliderWidth, itemWidth, firstItemAlignment, inactiveOpacity, inactiveScale, spaceBetween, spaceHeadTail, renderItem, onPageChange, scrollViewProps, keyExtractor, onItemPress }: CarouselProps<TData>): JSX.Element;
3
+ declare function Carousel<TData>({ style, data, initialPage, loop, additionalPagesPerSide, autoPlay, duration, animation, sliderWidth, itemWidth, firstItemAlignment, inactiveOpacity, inactiveScale, spaceBetween, spaceHeadTail, renderItem, onPageChange, scrollViewProps, keyExtractor, onItemPress, disableItemPress, scrollViewRef: externalScrollViewRef, }: CarouselProps<TData>): React.JSX.Element;
3
4
  export default Carousel;
5
+ //# sourceMappingURL=Carousel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../../src/components/Carousel.tsx"],"names":[],"mappings":"AACA,OAAO,KAKN,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA4C9C,iBAAS,QAAQ,CAAC,KAAK,EAAE,EACvB,KAAK,EACL,IAAI,EACJ,WAAe,EACf,IAAY,EACZ,sBAA0B,EAC1B,QAAgB,EAChB,QAAe,EACf,SAAS,EACT,WAA8B,EAC9B,SAA4B,EAC5B,kBAA6B,EAC7B,eAAmB,EACnB,aAAiB,EACjB,YAAgB,EAChB,aAAiB,EACjB,UAAU,EACV,YAAY,EACZ,eAAoB,EACpB,YAAY,EACZ,WAAW,EACX,gBAAwB,EACxB,aAAa,EAAE,qBAAqB,GACrC,EAAE,aAAa,CAAC,KAAK,CAAC,qBA6ctB;AAED,eAAe,QAAQ,CAAC"}
@@ -1,2 +1,3 @@
1
- import { FC } from 'react';
2
- export default function withCarouselContext<T>(Component: FC<T>): (props: T) => JSX.Element;
1
+ import React, { FC } from 'react';
2
+ export default function withCarouselContext<T>(Component: FC<T>): (props: T) => React.JSX.Element;
3
+ //# sourceMappingURL=CarouselContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CarouselContainer.d.ts","sourceRoot":"","sources":["../../../src/components/CarouselContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,EAAE,EAKH,MAAM,OAAO,CAAC;AA8Cf,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IACrD,OAAO,CAAC,uBAOjB"}
@@ -1,7 +1,8 @@
1
+ import React from 'react';
1
2
  import { StyleProp, ViewStyle } from 'react-native';
2
3
  import Animated from 'react-native-reanimated';
3
4
  import type { CarouselProps } from '../types';
4
- declare type Props<TData> = {
5
+ type Props<TData> = {
5
6
  item: TData;
6
7
  index: number;
7
8
  offset: number;
@@ -13,7 +14,8 @@ declare type Props<TData> = {
13
14
  inactiveOpacity: number;
14
15
  inactiveScale: number;
15
16
  containerStyle: StyleProp<ViewStyle>;
16
- onPress: () => void;
17
+ onPress?: () => void;
17
18
  };
18
- export default function PageItem<TData = any>({ item, index, offset, renderItem, animatedValue, animation, freeze, itemWidth, inactiveOpacity, inactiveScale, containerStyle, onPress, }: Props<TData>): JSX.Element;
19
+ export default function PageItem<TData = any>({ item, index, offset, renderItem, animatedValue, animation, freeze, itemWidth, inactiveOpacity, inactiveScale, containerStyle, onPress, }: Props<TData>): React.JSX.Element;
19
20
  export {};
21
+ //# sourceMappingURL=PageItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PageItem.d.ts","sourceRoot":"","sources":["../../../src/components/PageItem.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAGL,SAAS,EAET,SAAS,EACV,MAAM,cAAc,CAAC;AACtB,OAAO,QAIN,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,KAAK,KAAK,CAAC,KAAK,IAAI;IAClB,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACxC,aAAa,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAoCF,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAAK,GAAG,GAAG,EAAE,EAC5C,IAAI,EACJ,KAAK,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,SAAS,EACT,MAAM,EACN,SAAS,EACT,eAAe,EACf,aAAa,EACb,cAAc,EACd,OAAO,GACR,EAAE,KAAK,CAAC,KAAK,CAAC,qBAsEd"}
@@ -1,2 +1,4 @@
1
+ import React from 'react';
1
2
  import type { PaginationProps } from '../types';
2
- export default function PaginationIndicator({ containerStyle, indicatorStyle, activeIndicatorStyle, indicatorConfigs, }: PaginationProps): JSX.Element;
3
+ export default function PaginationIndicator({ containerStyle, indicatorStyle, activeIndicatorStyle, indicatorConfigs, }: PaginationProps): React.JSX.Element;
4
+ //# sourceMappingURL=PaginationIndicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaginationIndicator.d.ts","sourceRoot":"","sources":["../../../src/components/PaginationIndicator.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAOvC,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,UAAU,CAAC;AAoBlE,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,gBAAgB,GACjB,EAAE,eAAe,qBA0EjB"}
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
2
1
  import type { CarouselContextType } from '../types';
3
2
  export declare const CarouselContext: import("react").Context<CarouselContextType>;
4
3
  export declare function useCarouselContext(): CarouselContextType;
4
+ //# sourceMappingURL=useCarouselContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCarouselContext.d.ts","sourceRoot":"","sources":["../../../src/components/useCarouselContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGpD,eAAO,MAAM,eAAe,8CAAuC,CAAC;AAEpE,wBAAgB,kBAAkB,wBAMjC"}
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
2
1
  import type { CarouselContextInternalType } from '../types';
3
2
  export declare const InternalCarouselContext: import("react").Context<CarouselContextInternalType>;
4
3
  export declare function useInternalCarouselContext(): CarouselContextInternalType;
4
+ //# sourceMappingURL=useInternalCarouselContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInternalCarouselContext.d.ts","sourceRoot":"","sources":["../../../src/components/useInternalCarouselContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAE5D,eAAO,MAAM,uBAAuB,sDAElC,CAAC;AAEH,wBAAgB,0BAA0B,gCAGzC"}
@@ -4,3 +4,4 @@ export { default as PaginationIndicator } from './components/PaginationIndicator
4
4
  export * from './types';
5
5
  export * from './components/useCarouselContext';
6
6
  export default Carousel;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAElF,cAAc,SAAS,CAAC;AACxB,cAAc,iCAAiC,CAAA;AAE/C,eAAe,QAAQ,CAAC"}
@@ -1,7 +1,6 @@
1
- /// <reference types="react" />
2
1
  import type { ScrollViewProps, StyleProp, ViewStyle } from 'react-native';
3
- import type Animated from 'react-native-reanimated';
4
- export declare type CarouselProps<T = any> = {
2
+ import { SharedValue } from 'react-native-reanimated';
3
+ export type CarouselProps<T = any> = {
5
4
  style?: StyleProp<ViewStyle>;
6
5
  data: T[];
7
6
  initialPage?: number;
@@ -17,50 +16,53 @@ export declare type CarouselProps<T = any> = {
17
16
  inactiveScale?: number;
18
17
  spaceBetween?: number;
19
18
  spaceHeadTail?: number;
20
- animatedPage?: Animated.SharedValue<number>;
19
+ animatedPage?: SharedValue<number>;
21
20
  scrollViewProps?: ScrollViewProps;
22
21
  renderItem: (data: {
23
22
  item: T;
24
23
  index?: number;
25
24
  }, animatedData?: {
26
- scrollPosition?: Animated.SharedValue<number>;
25
+ scrollPosition?: SharedValue<number>;
27
26
  offset?: number;
28
27
  }) => React.ReactNode;
29
28
  onPageChange?: (index: number) => void;
30
29
  keyExtractor?: (item: T, index?: number) => string;
31
30
  onItemPress?: (item: T, index?: number) => void;
31
+ disableItemPress?: boolean;
32
+ scrollViewRef?: any;
32
33
  };
33
- export declare type CarouselHandles = {
34
+ export type CarouselHandles = {
34
35
  goNext(): void;
35
36
  goPrev(): void;
36
37
  snapToItem(index: number, animated?: boolean): void;
37
38
  };
38
- export declare type CarouselContextType = {
39
+ export type CarouselContextType = {
39
40
  goNext(): void;
40
41
  goPrev(): void;
41
42
  snapToItem(index: number, animated?: boolean): void;
42
- currentPage: Animated.SharedValue<number>;
43
- totalPage: Animated.SharedValue<number>;
43
+ currentPage: SharedValue<number>;
44
+ totalPage: SharedValue<number>;
44
45
  };
45
- export declare type CarouselContextInternalType = {
46
+ export type CarouselContextInternalType = {
46
47
  setCarouselHandlers: (handlers: any) => void;
47
48
  };
48
- export declare type AnimatorProps = {
49
- animatedValue: Animated.SharedValue<number>;
49
+ export type AnimatorProps = {
50
+ animatedValue: SharedValue<number>;
50
51
  offset: number;
51
- freeze: Animated.SharedValue<boolean>;
52
+ freeze: SharedValue<boolean>;
52
53
  itemWidth: number;
53
54
  };
54
- export declare type PaginationProps = {
55
+ export type PaginationProps = {
55
56
  containerStyle?: StyleProp<ViewStyle>;
56
57
  indicatorStyle?: Omit<StyleProp<ViewStyle>, 'width'>;
57
58
  activeIndicatorStyle?: Omit<StyleProp<ViewStyle>, 'width'>;
58
59
  indicatorConfigs?: IndicatorConfigs;
59
60
  };
60
- export declare type IndicatorConfigs = {
61
+ export type IndicatorConfigs = {
61
62
  indicatorColor?: string;
62
63
  indicatorWidth?: number;
63
64
  indicatorSelectedColor?: string;
64
65
  indicatorSelectedWidth?: number;
65
66
  spaceBetween?: number;
66
67
  };
68
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAA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B,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
@@ -4,4 +4,7 @@ export declare const generateOffsets: ({ sliderWidth, itemWidth, itemCount, hori
4
4
  itemCount: number;
5
5
  horizontalPadding: number;
6
6
  }) => number[];
7
- export declare const findNearestPage: (offset: number, offsets: number[], delta: number) => number;
7
+ export declare const findNearestPage: (offset: number, offsets: number[]) => number;
8
+ export declare function getLogicalPage(renderIndex: number, totalItems: number, additionalPagesPerSide: number, loop: boolean): number;
9
+ export declare function getLoopBoundaryTarget(renderPage: number, totalPages: number, additionalPagesPerSide: number): number;
10
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,2DAK7B;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,aAaA,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,SAAS,MAAM,EAAE,KAAG,MAanE,CAAC;AAEF,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,sBAAsB,EAAE,MAAM,EAC9B,IAAI,EAAE,OAAO,GACZ,MAAM,CAMR;AAED,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,sBAAsB,EAAE,MAAM,GAC7B,MAAM,CAUR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r0b0t3d/react-native-carousel",
3
- "version": "3.4.6",
3
+ "version": "3.4.8",
4
4
  "description": "React Native Carousel",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -20,7 +20,7 @@
20
20
  "test": "jest",
21
21
  "typescript": "tsc --noEmit",
22
22
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
23
- "prepare": "bob build",
23
+ "prepare": "husky",
24
24
  "release": "release-it",
25
25
  "example": "yarn --cwd example",
26
26
  "pods": "cd example && pod-install --quiet",
@@ -42,29 +42,32 @@
42
42
  "registry": "https://registry.npmjs.org/"
43
43
  },
44
44
  "dependencies": {
45
- "@r0b0t3d/react-native-hooks": "^1.0.2"
45
+ "@r0b0t3d/react-native-hooks": "^1.0.6"
46
46
  },
47
47
  "devDependencies": {
48
- "@commitlint/config-conventional": "^11.0.0",
49
- "@react-native-community/eslint-config": "^2.0.0",
50
- "@release-it/conventional-changelog": "^2.0.0",
51
- "@types/jest": "^26.0.0",
52
- "@types/react": "^16.9.19",
53
- "@types/react-native": "0.62.13",
54
- "commitlint": "^11.0.0",
55
- "eslint": "^7.2.0",
56
- "eslint-config-prettier": "^7.0.0",
57
- "eslint-plugin-prettier": "^3.1.3",
58
- "husky": "^4.2.5",
59
- "jest": "^26.0.1",
60
- "pod-install": "^0.1.0",
61
- "prettier": "^2.0.5",
62
- "react": "16.13.1",
63
- "react-native": "0.63.4",
64
- "react-native-builder-bob": "^0.18.1",
65
- "react-native-reanimated": "^2.1.0",
66
- "release-it": "^14.2.2",
67
- "typescript": "^4.1.3"
48
+ "@commitlint/cli": "^21.0.2",
49
+ "@commitlint/config-conventional": "^20.5.3",
50
+ "@react-native-community/eslint-config": "^3.2.0",
51
+ "@react-native/babel-preset": "^0.85.2",
52
+ "@release-it/conventional-changelog": "^11.0.0",
53
+ "@types/jest": "^30.0.0",
54
+ "@types/react": "^19.2.14",
55
+ "@typescript-eslint/eslint-plugin": "^8.61.0",
56
+ "@typescript-eslint/parser": "^8.61.0",
57
+ "eslint": "^10.3.0",
58
+ "eslint-config-prettier": "^10.1.8",
59
+ "eslint-plugin-prettier": "^5.5.5",
60
+ "husky": "^9.1.7",
61
+ "jest": "^30.3.0",
62
+ "prettier": "^3.8.3",
63
+ "react": "19.2.3",
64
+ "react-native": "0.85.2",
65
+ "react-native-builder-bob": "^0.41.0",
66
+ "react-native-reanimated": "^4.3.0",
67
+ "react-native-worklets": "^0.9.2",
68
+ "release-it": "^20.0.1",
69
+ "typescript": "^6.0.3",
70
+ "typescript-eslint": "^8.61.0"
68
71
  },
69
72
  "peerDependencies": {
70
73
  "react": "*",
@@ -78,12 +81,6 @@
78
81
  "<rootDir>/lib/"
79
82
  ]
80
83
  },
81
- "husky": {
82
- "hooks": {
83
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
84
- "pre-commit": "yarn lint && yarn typescript"
85
- }
86
- },
87
84
  "commitlint": {
88
85
  "extends": [
89
86
  "@commitlint/config-conventional"