Skip to content

Commit ed8c88c

Browse files
committed
fix: remove postinstall script
1 parent c6d58e5 commit ed8c88c

File tree

7 files changed

+136
-278
lines changed

7 files changed

+136
-278
lines changed

example/website/pages/concepts.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ So when the first one is at the origin `translateX:0`, the next one is at the or
132132
├── index.tsx
133133
├── layouts # Some basic layouts are defined
134134
│ ├── BaseLayout.tsx
135-
│ ├── ParallaxLayout.tsx
136135
│ ├── index.tsx # Layout entry file that returns the various animationStyles defined.
137136
│ ├── normal.ts
138137
│ ├── parallax.ts

src/layouts/BaseLayout.tsx renamed to src/components/BaseLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import Animated, {
88
useDerivedValue,
99
} from "react-native-reanimated";
1010

11-
import type { ILayoutConfig } from "./stack";
11+
import { LazyView } from "./LazyView";
1212

13-
import { LazyView } from "../components/LazyView";
1413
import { useCheckMounted } from "../hooks/useCheckMounted";
1514
import type { IOpts } from "../hooks/useOffsetX";
1615
import { useOffsetX } from "../hooks/useOffsetX";
1716
import type { IVisibleRanges } from "../hooks/useVisibleRanges";
17+
import type { ILayoutConfig } from "../layouts/stack";
1818
import { CTX } from "../store";
1919

2020
export type TAnimationStyle = (value: number) => AnimatedStyleProp<ViewStyle>;

src/components/Carousel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { StyleSheet } from "react-native";
33
import { GestureHandlerRootView } from "react-native-gesture-handler";
44
import { runOnJS, useDerivedValue } from "react-native-reanimated";
55

6+
import { BaseLayout } from "./BaseLayout";
67
import { ScrollViewGesture } from "./ScrollViewGesture";
78

89
import { useAutoPlay } from "../hooks/useAutoPlay";
@@ -13,7 +14,6 @@ import { useLayoutConfig } from "../hooks/useLayoutConfig";
1314
import { useOnProgressChange } from "../hooks/useOnProgressChange";
1415
import { usePropsErrorBoundary } from "../hooks/usePropsErrorBoundary";
1516
import { useVisibleRanges } from "../hooks/useVisibleRanges";
16-
import { BaseLayout } from "../layouts/BaseLayout";
1717
import { CTX } from "../store";
1818
import type { ICarouselInstance, TCarouselProps } from "../types";
1919
import { computedRealIndexWithAutoFillData } from "../utils/computed-with-auto-fill-data";

src/hooks/useLayoutConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React from "react";
22

33
import type { TInitializeCarouselProps } from "./useInitProps";
44

5+
import type { TAnimationStyle } from "../components/BaseLayout";
56
import { Layouts } from "../layouts";
6-
import type { TAnimationStyle } from "../layouts/BaseLayout";
77

88
type TLayoutConfigOpts<T> = TInitializeCarouselProps<T> & { size: number };
99

src/hooks/useOffsetX.test.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
import { useSharedValue } from 'react-native-reanimated';
1+
import { useSharedValue } from "react-native-reanimated";
22

3-
import { renderHook } from '@testing-library/react-hooks';
3+
import { renderHook } from "@testing-library/react-hooks";
44

5-
import type { IOpts } from './useOffsetX';
6-
import { useOffsetX } from './useOffsetX';
7-
import type { IVisibleRanges } from './useVisibleRanges';
5+
import type { IOpts } from "./useOffsetX";
6+
import { useOffsetX } from "./useOffsetX";
7+
import type { IVisibleRanges } from "./useVisibleRanges";
88

9-
describe('useSharedValue', () => {
10-
it('should return the correct values', async () => {
11-
const hook = renderHook(() => {
12-
const range = useSharedValue({
13-
negativeRange: [7, 9],
14-
positiveRange: [0, 3],
15-
});
16-
const inputs: Array<{
17-
config: IOpts;
18-
range: IVisibleRanges;
19-
}> = Array.from({ length: 10 }).map((_, index) => ({
20-
config: {
21-
dataLength: 10,
22-
handlerOffset: useSharedValue(-0),
23-
index: index,
24-
loop: false,
25-
size: 393,
26-
},
27-
range,
28-
}));
9+
describe("useSharedValue", () => {
10+
it("should return the correct values", async () => {
11+
const hook = renderHook(() => {
12+
const range = useSharedValue({
13+
negativeRange: [7, 9],
14+
positiveRange: [0, 3],
15+
});
16+
const inputs: Array<{
17+
config: IOpts
18+
range: IVisibleRanges
19+
}> = Array.from({ length: 10 }).map((_, index) => ({
20+
config: {
21+
dataLength: 10,
22+
handlerOffset: useSharedValue(-0),
23+
index,
24+
loop: false,
25+
size: 393,
26+
},
27+
range,
28+
}));
2929

30-
return inputs.map((input) => {
31-
const { config, range } = input;
30+
return inputs.map((input) => {
31+
const { config, range } = input;
3232

33-
return useOffsetX(config, range);
34-
});
35-
});
33+
return useOffsetX(config, range);
34+
});
35+
});
3636

37-
const expected = hook.result.current.map((v) => v.value).slice();
37+
const expected = hook.result.current.map(v => v.value).slice();
3838

39-
expect(expected).toMatchInlineSnapshot(`
39+
expect(expected).toMatchInlineSnapshot(`
4040
[
4141
0,
4242
393,
@@ -50,5 +50,5 @@ describe('useSharedValue', () => {
5050
3537,
5151
]
5252
`);
53-
});
53+
});
5454
});
Lines changed: 99 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import { useSharedValue } from 'react-native-reanimated';
1+
import { useSharedValue } from "react-native-reanimated";
22

3-
import { renderHook } from '@testing-library/react-hooks';
3+
import { renderHook } from "@testing-library/react-hooks";
44

5-
import { useVisibleRanges } from './useVisibleRanges';
5+
import { useVisibleRanges } from "./useVisibleRanges";
66

77
const viewSize = 393;
88

9-
describe('useVisibleRanges', () => {
10-
it('should only display the front of the list when loop is false', async () => {
11-
const hook = renderHook(() => {
12-
const translation = useSharedValue(-0);
13-
const range = useVisibleRanges({
14-
total: 10,
15-
translation,
16-
viewSize,
17-
windowSize: 4,
18-
loop: false,
19-
});
20-
21-
return range;
22-
});
9+
describe("useVisibleRanges", () => {
10+
it("should only display the front of the list when loop is false", async () => {
11+
const hook = renderHook(() => {
12+
const translation = useSharedValue(-0);
13+
const range = useVisibleRanges({
14+
total: 10,
15+
translation,
16+
viewSize,
17+
windowSize: 4,
18+
loop: false,
19+
});
20+
21+
return range;
22+
});
2323

24-
const expected = hook.result.current.value;
24+
const expected = hook.result.current.value;
2525

26-
expect(expected).toMatchInlineSnapshot(`
26+
expect(expected).toMatchInlineSnapshot(`
2727
{
2828
"negativeRange": [
2929
-3,
@@ -35,25 +35,25 @@ describe('useVisibleRanges', () => {
3535
],
3636
}
3737
`);
38+
});
39+
40+
it("should display the rear of the list and the front of the list when loop is true", async () => {
41+
const hook = renderHook(() => {
42+
const translation = useSharedValue(-0);
43+
const range = useVisibleRanges({
44+
total: 10,
45+
translation,
46+
viewSize,
47+
windowSize: 4,
48+
loop: true,
49+
});
50+
51+
return range;
3852
});
3953

40-
it('should display the rear of the list and the front of the list when loop is true', async () => {
41-
const hook = renderHook(() => {
42-
const translation = useSharedValue(-0);
43-
const range = useVisibleRanges({
44-
total: 10,
45-
translation,
46-
viewSize,
47-
windowSize: 4,
48-
loop: true,
49-
});
50-
51-
return range;
52-
});
53-
54-
const expected = hook.result.current.value;
54+
const expected = hook.result.current.value;
5555

56-
expect(expected).toMatchInlineSnapshot(`
56+
expect(expected).toMatchInlineSnapshot(`
5757
{
5858
"negativeRange": [
5959
8,
@@ -65,63 +65,63 @@ describe('useVisibleRanges', () => {
6565
],
6666
}
6767
`);
68-
});
69-
70-
it('should shows the increased range of the list when the loop is false and swiped the carousel.', async () => {
71-
const slide0hook = renderHook(() => {
72-
const translation = useSharedValue(-0 * viewSize);
73-
const range = useVisibleRanges({
74-
total: 10,
75-
translation,
76-
viewSize,
77-
windowSize: 4,
78-
loop: false,
79-
});
80-
81-
return range;
82-
}).result.current.value;
83-
84-
const slide1hook = renderHook(() => {
85-
const translation = useSharedValue(-1 * viewSize);
86-
const range = useVisibleRanges({
87-
total: 10,
88-
translation,
89-
viewSize,
90-
windowSize: 4,
91-
loop: false,
92-
});
93-
94-
return range;
95-
}).result.current.value;
96-
97-
const slide2hook = renderHook(() => {
98-
const translation = useSharedValue(-2 * viewSize);
99-
const range = useVisibleRanges({
100-
total: 10,
101-
translation,
102-
viewSize,
103-
windowSize: 4,
104-
loop: false,
105-
});
106-
107-
return range;
108-
}).result.current.value;
109-
110-
const slide3hook = renderHook(() => {
111-
const translation = useSharedValue(-3 * viewSize);
112-
const range = useVisibleRanges({
113-
total: 10,
114-
translation,
115-
viewSize,
116-
windowSize: 4,
117-
loop: false,
118-
});
119-
120-
return range;
121-
}).result.current.value;
122-
123-
// [0,3] Display the 0,1,2,3 items.
124-
expect(slide0hook).toMatchInlineSnapshot(`
68+
});
69+
70+
it("should shows the increased range of the list when the loop is false and swiped the carousel.", async () => {
71+
const slide0hook = renderHook(() => {
72+
const translation = useSharedValue(-0 * viewSize);
73+
const range = useVisibleRanges({
74+
total: 10,
75+
translation,
76+
viewSize,
77+
windowSize: 4,
78+
loop: false,
79+
});
80+
81+
return range;
82+
}).result.current.value;
83+
84+
const slide1hook = renderHook(() => {
85+
const translation = useSharedValue(-1 * viewSize);
86+
const range = useVisibleRanges({
87+
total: 10,
88+
translation,
89+
viewSize,
90+
windowSize: 4,
91+
loop: false,
92+
});
93+
94+
return range;
95+
}).result.current.value;
96+
97+
const slide2hook = renderHook(() => {
98+
const translation = useSharedValue(-2 * viewSize);
99+
const range = useVisibleRanges({
100+
total: 10,
101+
translation,
102+
viewSize,
103+
windowSize: 4,
104+
loop: false,
105+
});
106+
107+
return range;
108+
}).result.current.value;
109+
110+
const slide3hook = renderHook(() => {
111+
const translation = useSharedValue(-3 * viewSize);
112+
const range = useVisibleRanges({
113+
total: 10,
114+
translation,
115+
viewSize,
116+
windowSize: 4,
117+
loop: false,
118+
});
119+
120+
return range;
121+
}).result.current.value;
122+
123+
// [0,3] Display the 0,1,2,3 items.
124+
expect(slide0hook).toMatchInlineSnapshot(`
125125
{
126126
"negativeRange": [
127127
-3,
@@ -134,8 +134,8 @@ describe('useVisibleRanges', () => {
134134
}
135135
`);
136136

137-
// [1,4] Display the 1,2,3,4 items.
138-
expect(slide1hook).toMatchInlineSnapshot(`
137+
// [1,4] Display the 1,2,3,4 items.
138+
expect(slide1hook).toMatchInlineSnapshot(`
139139
{
140140
"negativeRange": [
141141
-2,
@@ -148,8 +148,8 @@ describe('useVisibleRanges', () => {
148148
}
149149
`);
150150

151-
// [2,5] Display the 2,3,4,5 items.
152-
expect(slide2hook).toMatchInlineSnapshot(`
151+
// [2,5] Display the 2,3,4,5 items.
152+
expect(slide2hook).toMatchInlineSnapshot(`
153153
{
154154
"negativeRange": [
155155
-1,
@@ -162,8 +162,8 @@ describe('useVisibleRanges', () => {
162162
}
163163
`);
164164

165-
// [3.6] Display the 3,4,5,6 items.
166-
expect(slide3hook).toMatchInlineSnapshot(`
165+
// [3.6] Display the 3,4,5,6 items.
166+
expect(slide3hook).toMatchInlineSnapshot(`
167167
{
168168
"negativeRange": [
169169
0,
@@ -175,5 +175,5 @@ describe('useVisibleRanges', () => {
175175
],
176176
}
177177
`);
178-
});
178+
});
179179
});

0 commit comments

Comments
 (0)