@lookiero/checkout 0.8.4-beta.2 → 0.8.4-beta.3
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.
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { Animated,
|
|
3
|
-
|
|
4
|
-
// import { Pagination } from "./Pagination";
|
|
2
|
+
import { Animated, I18nManager, PanResponder, StyleSheet, View, } from "react-native";
|
|
3
|
+
import { Pagination } from "./Pagination";
|
|
5
4
|
import { style } from "./Slider.style";
|
|
6
5
|
const DEFAULT_WIDTH = 200;
|
|
7
|
-
const Slider = ({ children, active = 0, loop = false, minDistanceToCapture = 5, minDistanceForAction = 0.2, gesturesEnabled = true,
|
|
8
|
-
// paginationEnabled = true,
|
|
9
|
-
// paginationStyle,
|
|
10
|
-
// paginationItemStyle,
|
|
11
|
-
// paginationActiveItemStyle,
|
|
12
|
-
onSliderStart, onSliderEnd, onChanged,
|
|
13
|
-
// paginationRenderItem,
|
|
14
|
-
}) => {
|
|
6
|
+
const Slider = ({ children, active = 0, loop = false, minDistanceToCapture = 5, minDistanceForAction = 0.2, gesturesEnabled = true, paginationEnabled = true, paginationStyle, paginationItemStyle, paginationActiveItemStyle, onSliderStart, onSliderEnd, onChanged, paginationRenderItem, }) => {
|
|
15
7
|
const flatennedChildren = children.flat();
|
|
16
8
|
const count = flatennedChildren.length;
|
|
17
9
|
const [width, setWidth] = useState(0);
|
|
@@ -108,7 +100,7 @@ onSliderStart, onSliderEnd, onChanged,
|
|
|
108
100
|
fixAndGo(delta);
|
|
109
101
|
}
|
|
110
102
|
}, [fixAndGo]);
|
|
111
|
-
|
|
103
|
+
const getActiveIndex = useCallback(() => activeIndex.current, []);
|
|
112
104
|
useEffect(() => {
|
|
113
105
|
pan.x.addListener(({ value }) => (animatedValueX.current = value));
|
|
114
106
|
pan.y.addListener(({ value }) => (animatedValueY.current = value));
|
|
@@ -128,40 +120,13 @@ onSliderStart, onSliderEnd, onChanged,
|
|
|
128
120
|
widthRef.current = width;
|
|
129
121
|
fixState();
|
|
130
122
|
}, [fixState]);
|
|
131
|
-
return (
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// ])}
|
|
140
|
-
// {...panResponder.panHandlers}
|
|
141
|
-
// >
|
|
142
|
-
// {flatennedChildren.map((child, index) => (
|
|
143
|
-
// <View key={index} style={{ width }} testID="slider-child">
|
|
144
|
-
// {child}
|
|
145
|
-
// </View>
|
|
146
|
-
// ))}
|
|
147
|
-
// </Animated.View>
|
|
148
|
-
// {paginationEnabled && (
|
|
149
|
-
// <Pagination
|
|
150
|
-
// activeIndex={getActiveIndex()}
|
|
151
|
-
// count={count}
|
|
152
|
-
// paginationActiveItemStyle={paginationActiveItemStyle}
|
|
153
|
-
// paginationItemStyle={paginationItemStyle}
|
|
154
|
-
// paginationStyle={paginationStyle}
|
|
155
|
-
// renderItem={paginationRenderItem}
|
|
156
|
-
// onChange={(index) => goTo(index)}
|
|
157
|
-
// />
|
|
158
|
-
// )}
|
|
159
|
-
// </View>
|
|
160
|
-
React.createElement(Animated.View, { style: StyleSheet.flatten([
|
|
161
|
-
{
|
|
162
|
-
transform: [{ translateX: pan.x }, { translateY: pan.y }],
|
|
163
|
-
},
|
|
164
|
-
style.sliderAreaStyle,
|
|
165
|
-
]), onLayout: onLayoutWrapper, ...panResponder.panHandlers }, flatennedChildren.map((child, index) => (React.createElement(View, { key: index, style: { width: "100%" }, testID: "slider-child" }, child)))));
|
|
123
|
+
return (React.createElement(View, { style: style.container, testID: "slider", onLayout: onLayoutWrapper },
|
|
124
|
+
React.createElement(Animated.View, { style: StyleSheet.flatten([
|
|
125
|
+
{
|
|
126
|
+
left: pan.x,
|
|
127
|
+
},
|
|
128
|
+
style.sliderAreaStyle,
|
|
129
|
+
]), ...panResponder.panHandlers }, flatennedChildren.map((child, index) => (React.createElement(View, { key: index, style: { width }, testID: "slider-child" }, child)))),
|
|
130
|
+
paginationEnabled && (React.createElement(Pagination, { activeIndex: getActiveIndex(), count: count, paginationActiveItemStyle: paginationActiveItemStyle, paginationItemStyle: paginationItemStyle, paginationStyle: paginationStyle, renderItem: paginationRenderItem, onChange: (index) => goTo(index) }))));
|
|
166
131
|
};
|
|
167
132
|
export { Slider };
|