@momo-kits/carousel 0.80.1-beta.2 → 0.80.4-beta.2
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/animation.ts +18 -6
- package/index.tsx +154 -301
- package/package.json +1 -1
- package/types.ts +19 -34
- package/newCarousel.tsx +0 -1041
package/newCarousel.tsx
DELETED
|
@@ -1,1041 +0,0 @@
|
|
|
1
|
-
// import React from 'react';
|
|
2
|
-
// import {
|
|
3
|
-
// Animated,
|
|
4
|
-
// I18nManager,
|
|
5
|
-
// LayoutChangeEvent,
|
|
6
|
-
// NativeScrollEvent,
|
|
7
|
-
// NativeSyntheticEvent,
|
|
8
|
-
// Platform,
|
|
9
|
-
// View,
|
|
10
|
-
// } from 'react-native';
|
|
11
|
-
// import {defaultAnimatedStyles, defaultScrollInterpolator} from './animation';
|
|
12
|
-
// import {CarouselProps, CarouselState, Position} from './types';
|
|
13
|
-
//
|
|
14
|
-
// const IS_ANDROID = Platform.OS === 'android';
|
|
15
|
-
// const IS_IOS = Platform.OS === 'ios';
|
|
16
|
-
// const IS_RTL = I18nManager.isRTL;
|
|
17
|
-
//
|
|
18
|
-
// export default class Carousel extends React.PureComponent<
|
|
19
|
-
// CarouselProps,
|
|
20
|
-
// CarouselState
|
|
21
|
-
// > {
|
|
22
|
-
// static defaultProps = {
|
|
23
|
-
// activeSlideAlignment: 'center',
|
|
24
|
-
// activeSlideOffset: 20,
|
|
25
|
-
// apparitionDelay: 0,
|
|
26
|
-
// autoplay: false,
|
|
27
|
-
// autoplayDelay: 1000,
|
|
28
|
-
// autoplayInterval: 3000,
|
|
29
|
-
// callbackOffsetMargin: 5,
|
|
30
|
-
// containerCustomStyle: {},
|
|
31
|
-
// contentContainerCustomStyle: {},
|
|
32
|
-
// enableSnap: true,
|
|
33
|
-
// firstItem: 0,
|
|
34
|
-
// hasParallaxImages: false,
|
|
35
|
-
// inactiveSlideOpacity: 0.7,
|
|
36
|
-
// inactiveSlideScale: 0.9,
|
|
37
|
-
// inactiveSlideShift: 0,
|
|
38
|
-
// layout: 'default',
|
|
39
|
-
// loop: false,
|
|
40
|
-
// loopClonesPerSide: 3,
|
|
41
|
-
// scrollEnabled: true,
|
|
42
|
-
// slideStyle: {},
|
|
43
|
-
// shouldOptimizeUpdates: true,
|
|
44
|
-
// useScrollView: !Animated.FlatList,
|
|
45
|
-
// vertical: false,
|
|
46
|
-
// isCustomScrollWidth: false,
|
|
47
|
-
// disableIntervalMomentum: IS_ANDROID,
|
|
48
|
-
// useExperimentalSnap: IS_ANDROID,
|
|
49
|
-
// };
|
|
50
|
-
//
|
|
51
|
-
// _activeItem;
|
|
52
|
-
// _onScrollActiveItem;
|
|
53
|
-
// _previousFirstItem;
|
|
54
|
-
// _previousItemsLength;
|
|
55
|
-
// _mounted;
|
|
56
|
-
// _positions: Position[];
|
|
57
|
-
// _currentScrollOffset;
|
|
58
|
-
// _scrollEnabled;
|
|
59
|
-
// _initTimeout?: NodeJS.Timeout;
|
|
60
|
-
// _apparitionTimeout?: NodeJS.Timeout;
|
|
61
|
-
// _hackSlideAnimationTimeout?: NodeJS.Timeout;
|
|
62
|
-
// _enableAutoplayTimeout?: NodeJS.Timeout;
|
|
63
|
-
// _autoplayTimeout?: NodeJS.Timeout;
|
|
64
|
-
// _snapNoMomentumTimeout?: NodeJS.Timeout;
|
|
65
|
-
// _androidRepositioningTimeout?: NodeJS.Timeout;
|
|
66
|
-
// _scrollPos?: Animated.Value;
|
|
67
|
-
// _onScrollHandler?: (...args: any[]) => void;
|
|
68
|
-
// _autoplay?: boolean;
|
|
69
|
-
// _autoplaying?: boolean;
|
|
70
|
-
// _autoplayInterval?: NodeJS.Timeout;
|
|
71
|
-
// _carouselRef?: {scrollTo: any; scrollToOffset: any; getNode: () => any};
|
|
72
|
-
// _onLayoutInitDone?: boolean;
|
|
73
|
-
// constructor(props: CarouselProps) {
|
|
74
|
-
// super(props);
|
|
75
|
-
//
|
|
76
|
-
// this.state = {
|
|
77
|
-
// hideCarousel: !!props.apparitionDelay,
|
|
78
|
-
// interpolators: [],
|
|
79
|
-
// };
|
|
80
|
-
//
|
|
81
|
-
// const initialActiveItem = this._getFirstItem(props.firstItem);
|
|
82
|
-
// this._activeItem = initialActiveItem;
|
|
83
|
-
// this._onScrollActiveItem = initialActiveItem;
|
|
84
|
-
// this._previousFirstItem = initialActiveItem;
|
|
85
|
-
// this._previousItemsLength = initialActiveItem;
|
|
86
|
-
//
|
|
87
|
-
// this._mounted = false;
|
|
88
|
-
// this._positions = [];
|
|
89
|
-
// this._currentScrollOffset = 0;
|
|
90
|
-
// this._scrollEnabled = props.scrollEnabled;
|
|
91
|
-
//
|
|
92
|
-
// this._getItemLayout = this._getItemLayout.bind(this);
|
|
93
|
-
// this._getKeyExtractor = this._getKeyExtractor.bind(this);
|
|
94
|
-
// this._onLayout = this._onLayout.bind(this);
|
|
95
|
-
// this._onScroll = this._onScroll.bind(this);
|
|
96
|
-
// this._onMomentumScrollEnd = this._onMomentumScrollEnd.bind(this);
|
|
97
|
-
// this._onTouchStart = this._onTouchStart.bind(this);
|
|
98
|
-
// this._onTouchEnd = this._onTouchEnd.bind(this);
|
|
99
|
-
// this._renderItem = this._renderItem.bind(this);
|
|
100
|
-
// this._setScrollHandler(props);
|
|
101
|
-
// }
|
|
102
|
-
//
|
|
103
|
-
// get realIndex() {
|
|
104
|
-
// return this._activeItem;
|
|
105
|
-
// }
|
|
106
|
-
//
|
|
107
|
-
// get currentIndex() {
|
|
108
|
-
// return this._getDataIndex(this._activeItem);
|
|
109
|
-
// }
|
|
110
|
-
//
|
|
111
|
-
// get currentScrollPosition() {
|
|
112
|
-
// return this._currentScrollOffset;
|
|
113
|
-
// }
|
|
114
|
-
//
|
|
115
|
-
// componentDidMount() {
|
|
116
|
-
// const {apparitionDelay, autoplay, firstItem} = this.props;
|
|
117
|
-
//
|
|
118
|
-
// this._mounted = true;
|
|
119
|
-
// this._initPositionsAndInterpolators();
|
|
120
|
-
//
|
|
121
|
-
// // Without 'requestAnimationFrame' or a `0` timeout, images will randomly not be rendered on Android...
|
|
122
|
-
// this._initTimeout = setTimeout(() => {
|
|
123
|
-
// if (!this._mounted) {
|
|
124
|
-
// return;
|
|
125
|
-
// }
|
|
126
|
-
//
|
|
127
|
-
// const apparitionCallback = () => {
|
|
128
|
-
// if (apparitionDelay) {
|
|
129
|
-
// this.setState({hideCarousel: false});
|
|
130
|
-
// }
|
|
131
|
-
// if (autoplay) {
|
|
132
|
-
// this.startAutoplay();
|
|
133
|
-
// }
|
|
134
|
-
// };
|
|
135
|
-
//
|
|
136
|
-
// // FlatList will use its own built-in prop `initialScrollIndex`
|
|
137
|
-
// if (this._needsScrollView()) {
|
|
138
|
-
// const _firstItem = this._getFirstItem(firstItem);
|
|
139
|
-
// this._snapToItem(_firstItem, false, false, true);
|
|
140
|
-
// // this._hackActiveSlideAnimation(_firstItem);
|
|
141
|
-
// }
|
|
142
|
-
//
|
|
143
|
-
// if (apparitionDelay) {
|
|
144
|
-
// this._apparitionTimeout = setTimeout(() => {
|
|
145
|
-
// apparitionCallback();
|
|
146
|
-
// }, apparitionDelay);
|
|
147
|
-
// } else {
|
|
148
|
-
// apparitionCallback();
|
|
149
|
-
// }
|
|
150
|
-
// }, 1);
|
|
151
|
-
// }
|
|
152
|
-
//
|
|
153
|
-
// componentDidUpdate(prevProps: CarouselProps) {
|
|
154
|
-
// const {interpolators} = this.state;
|
|
155
|
-
// const {firstItem, scrollEnabled} = this.props;
|
|
156
|
-
// const itemsLength = this._getCustomDataLength(this.props);
|
|
157
|
-
//
|
|
158
|
-
// if (!itemsLength) {
|
|
159
|
-
// return;
|
|
160
|
-
// }
|
|
161
|
-
//
|
|
162
|
-
// const nextFirstItem = this._getFirstItem(firstItem, this.props);
|
|
163
|
-
// let nextActiveItem =
|
|
164
|
-
// typeof this._activeItem !== 'undefined'
|
|
165
|
-
// ? this._activeItem
|
|
166
|
-
// : nextFirstItem;
|
|
167
|
-
//
|
|
168
|
-
// const hasNewSize =
|
|
169
|
-
// prevProps.itemWidth !== this.props.itemWidth ||
|
|
170
|
-
// prevProps.sliderWidth !== this.props.sliderWidth;
|
|
171
|
-
//
|
|
172
|
-
// if (nextActiveItem > itemsLength - 1) {
|
|
173
|
-
// nextActiveItem = itemsLength - 1;
|
|
174
|
-
// }
|
|
175
|
-
//
|
|
176
|
-
// if (scrollEnabled !== prevProps.scrollEnabled) {
|
|
177
|
-
// this._setScrollEnabled(scrollEnabled);
|
|
178
|
-
// }
|
|
179
|
-
//
|
|
180
|
-
// if (interpolators.length !== itemsLength || hasNewSize) {
|
|
181
|
-
// this._activeItem = nextActiveItem;
|
|
182
|
-
// this._previousItemsLength = itemsLength;
|
|
183
|
-
//
|
|
184
|
-
// this._initPositionsAndInterpolators(this.props);
|
|
185
|
-
//
|
|
186
|
-
// if (this._previousItemsLength > itemsLength) {
|
|
187
|
-
// this._hackActiveSlideAnimation(nextActiveItem);
|
|
188
|
-
// }
|
|
189
|
-
//
|
|
190
|
-
// if (hasNewSize) {
|
|
191
|
-
// this._snapToItem(nextActiveItem, false, false, true);
|
|
192
|
-
// }
|
|
193
|
-
// } else if (
|
|
194
|
-
// nextFirstItem !== this._previousFirstItem &&
|
|
195
|
-
// nextFirstItem !== this._activeItem
|
|
196
|
-
// ) {
|
|
197
|
-
// this._activeItem = nextFirstItem;
|
|
198
|
-
// this._previousFirstItem = nextFirstItem;
|
|
199
|
-
// this._snapToItem(nextFirstItem, false, true, true);
|
|
200
|
-
// }
|
|
201
|
-
//
|
|
202
|
-
// if (this.props.onScroll !== prevProps.onScroll) {
|
|
203
|
-
// this._setScrollHandler(this.props);
|
|
204
|
-
// }
|
|
205
|
-
// }
|
|
206
|
-
//
|
|
207
|
-
// componentWillUnmount() {
|
|
208
|
-
// this._mounted = false;
|
|
209
|
-
// this.stopAutoplay();
|
|
210
|
-
// clearTimeout(this._initTimeout);
|
|
211
|
-
// clearTimeout(this._apparitionTimeout);
|
|
212
|
-
// clearTimeout(this._hackSlideAnimationTimeout);
|
|
213
|
-
// clearTimeout(this._enableAutoplayTimeout);
|
|
214
|
-
// clearTimeout(this._autoplayTimeout);
|
|
215
|
-
// clearTimeout(this._snapNoMomentumTimeout);
|
|
216
|
-
// clearTimeout(this._androidRepositioningTimeout);
|
|
217
|
-
// }
|
|
218
|
-
//
|
|
219
|
-
// _setScrollHandler(props: CarouselProps) {
|
|
220
|
-
// const scrollEventConfig = {
|
|
221
|
-
// listener: this._onScroll,
|
|
222
|
-
// useNativeDriver: true,
|
|
223
|
-
// };
|
|
224
|
-
// this._scrollPos = new Animated.Value(0);
|
|
225
|
-
// const argMapping = [{nativeEvent: {contentOffset: {x: this._scrollPos}}}];
|
|
226
|
-
//
|
|
227
|
-
// if (props.onScroll && Array.isArray(props.onScroll._argMapping)) {
|
|
228
|
-
// argMapping.pop();
|
|
229
|
-
// const [argMap] = props.onScroll._argMapping;
|
|
230
|
-
// if (argMap && argMap.nativeEvent && argMap.nativeEvent.contentOffset) {
|
|
231
|
-
// this._scrollPos =
|
|
232
|
-
// argMap.nativeEvent.contentOffset.x ||
|
|
233
|
-
// argMap.nativeEvent.contentOffset.y ||
|
|
234
|
-
// this._scrollPos;
|
|
235
|
-
// }
|
|
236
|
-
// argMapping.push(...props.onScroll._argMapping);
|
|
237
|
-
// }
|
|
238
|
-
// this._onScrollHandler = Animated.event(argMapping, scrollEventConfig);
|
|
239
|
-
// }
|
|
240
|
-
//
|
|
241
|
-
// _needsScrollView() {
|
|
242
|
-
// const {useScrollView} = this.props;
|
|
243
|
-
// return IS_ANDROID
|
|
244
|
-
// ? useScrollView || !Animated.FlatList
|
|
245
|
-
// : useScrollView || !Animated.FlatList;
|
|
246
|
-
// }
|
|
247
|
-
//
|
|
248
|
-
// _needsRTLAdaptations() {
|
|
249
|
-
// return IS_RTL && IS_ANDROID;
|
|
250
|
-
// }
|
|
251
|
-
//
|
|
252
|
-
// _enableLoop() {
|
|
253
|
-
// const {data, enableSnap, loop} = this.props;
|
|
254
|
-
// return enableSnap && loop && data && data.length && data.length > 1;
|
|
255
|
-
// }
|
|
256
|
-
//
|
|
257
|
-
// _shouldAnimateSlides(props = this.props) {
|
|
258
|
-
// const {
|
|
259
|
-
// inactiveSlideOpacity,
|
|
260
|
-
// inactiveSlideScale,
|
|
261
|
-
// scrollInterpolator,
|
|
262
|
-
// slideInterpolatedStyle,
|
|
263
|
-
// } = props;
|
|
264
|
-
// return (
|
|
265
|
-
// inactiveSlideOpacity < 1 ||
|
|
266
|
-
// inactiveSlideScale < 1 ||
|
|
267
|
-
// !!scrollInterpolator ||
|
|
268
|
-
// !!slideInterpolatedStyle
|
|
269
|
-
// );
|
|
270
|
-
// }
|
|
271
|
-
//
|
|
272
|
-
// _shouldRepositionScroll(index: number) {
|
|
273
|
-
// const {data, enableSnap, loopClonesPerSide} = this.props;
|
|
274
|
-
// const dataLength = data && data.length;
|
|
275
|
-
// return !(
|
|
276
|
-
// !enableSnap ||
|
|
277
|
-
// !dataLength ||
|
|
278
|
-
// !this._enableLoop() ||
|
|
279
|
-
// (index >= loopClonesPerSide && index < dataLength + loopClonesPerSide)
|
|
280
|
-
// );
|
|
281
|
-
// }
|
|
282
|
-
//
|
|
283
|
-
// _isMultiple(x: number, y: number) {
|
|
284
|
-
// return Math.round(Math.round(x / y) / (1 / y)) === Math.round(x);
|
|
285
|
-
// }
|
|
286
|
-
//
|
|
287
|
-
// _getCustomData(props = this.props) {
|
|
288
|
-
// const {data, loopClonesPerSide} = props;
|
|
289
|
-
// const dataLength = data && data.length;
|
|
290
|
-
//
|
|
291
|
-
// if (!dataLength) {
|
|
292
|
-
// return [];
|
|
293
|
-
// }
|
|
294
|
-
//
|
|
295
|
-
// if (!this._enableLoop()) {
|
|
296
|
-
// return data;
|
|
297
|
-
// }
|
|
298
|
-
//
|
|
299
|
-
// let previousItems = [];
|
|
300
|
-
// let nextItems = [];
|
|
301
|
-
//
|
|
302
|
-
// if (loopClonesPerSide > dataLength) {
|
|
303
|
-
// const dataMultiplier = Math.floor(loopClonesPerSide / dataLength);
|
|
304
|
-
// const remainder = loopClonesPerSide % dataLength;
|
|
305
|
-
//
|
|
306
|
-
// for (let i = 0; i < dataMultiplier; i++) {
|
|
307
|
-
// previousItems.push(...data);
|
|
308
|
-
// nextItems.push(...data);
|
|
309
|
-
// }
|
|
310
|
-
//
|
|
311
|
-
// previousItems.unshift(...data.slice(-remainder));
|
|
312
|
-
// nextItems.push(...data.slice(0, remainder));
|
|
313
|
-
// } else {
|
|
314
|
-
// previousItems = data.slice(-loopClonesPerSide);
|
|
315
|
-
// nextItems = data.slice(0, loopClonesPerSide);
|
|
316
|
-
// }
|
|
317
|
-
//
|
|
318
|
-
// return previousItems.concat(data, nextItems);
|
|
319
|
-
// }
|
|
320
|
-
//
|
|
321
|
-
// _getCustomDataLength(props = this.props) {
|
|
322
|
-
// const {data, loopClonesPerSide} = props;
|
|
323
|
-
// const dataLength = data && data.length;
|
|
324
|
-
//
|
|
325
|
-
// if (!dataLength) {
|
|
326
|
-
// return 0;
|
|
327
|
-
// }
|
|
328
|
-
//
|
|
329
|
-
// return this._enableLoop() ? dataLength + 2 * loopClonesPerSide : dataLength;
|
|
330
|
-
// }
|
|
331
|
-
//
|
|
332
|
-
// _getCustomIndex(index: number, props = this.props) {
|
|
333
|
-
// const itemsLength = this._getCustomDataLength(props);
|
|
334
|
-
//
|
|
335
|
-
// if (!itemsLength || typeof index === 'undefined') {
|
|
336
|
-
// return 0;
|
|
337
|
-
// }
|
|
338
|
-
//
|
|
339
|
-
// return this._needsRTLAdaptations() ? itemsLength - index - 1 : index;
|
|
340
|
-
// }
|
|
341
|
-
//
|
|
342
|
-
// _getDataIndex(index: number) {
|
|
343
|
-
// const {data, loopClonesPerSide} = this.props;
|
|
344
|
-
// const dataLength = data && data.length;
|
|
345
|
-
// if (!this._enableLoop() || !dataLength) {
|
|
346
|
-
// return index;
|
|
347
|
-
// }
|
|
348
|
-
//
|
|
349
|
-
// if (index >= dataLength + loopClonesPerSide) {
|
|
350
|
-
// return loopClonesPerSide > dataLength
|
|
351
|
-
// ? (index - loopClonesPerSide) % dataLength
|
|
352
|
-
// : index - dataLength - loopClonesPerSide;
|
|
353
|
-
// } else if (index < loopClonesPerSide) {
|
|
354
|
-
// if (loopClonesPerSide > dataLength) {
|
|
355
|
-
// const baseDataIndexes = [];
|
|
356
|
-
// const dataIndexes = [];
|
|
357
|
-
// const dataMultiplier = Math.floor(loopClonesPerSide / dataLength);
|
|
358
|
-
// const remainder = loopClonesPerSide % dataLength;
|
|
359
|
-
//
|
|
360
|
-
// for (let i = 0; i < dataLength; i++) {
|
|
361
|
-
// baseDataIndexes.push(i);
|
|
362
|
-
// }
|
|
363
|
-
//
|
|
364
|
-
// for (let j = 0; j < dataMultiplier; j++) {
|
|
365
|
-
// dataIndexes.push(...baseDataIndexes);
|
|
366
|
-
// }
|
|
367
|
-
//
|
|
368
|
-
// dataIndexes.unshift(...baseDataIndexes.slice(-remainder));
|
|
369
|
-
// return dataIndexes[index];
|
|
370
|
-
// } else {
|
|
371
|
-
// return index + dataLength - loopClonesPerSide;
|
|
372
|
-
// }
|
|
373
|
-
// } else {
|
|
374
|
-
// return index - loopClonesPerSide;
|
|
375
|
-
// }
|
|
376
|
-
// }
|
|
377
|
-
// //
|
|
378
|
-
// // _getPositionIndex(index: number) {
|
|
379
|
-
// // const {loop, loopClonesPerSide} = this.props;
|
|
380
|
-
// // return loop ? index + loopClonesPerSide : index;
|
|
381
|
-
// // }
|
|
382
|
-
//
|
|
383
|
-
// _getSnapOffsets(props = this.props) {
|
|
384
|
-
// const offset = this._getItemMainDimension();
|
|
385
|
-
// if (!props.enableSnap) return;
|
|
386
|
-
// return [...Array(this._getCustomDataLength(props))].map((_, i) => {
|
|
387
|
-
// return i * offset;
|
|
388
|
-
// });
|
|
389
|
-
// }
|
|
390
|
-
//
|
|
391
|
-
// _getFirstItem(index: number, props = this.props) {
|
|
392
|
-
// const {loopClonesPerSide} = props;
|
|
393
|
-
// const itemsLength = this._getCustomDataLength(props);
|
|
394
|
-
//
|
|
395
|
-
// if (!itemsLength || index > itemsLength - 1 || index < 0) {
|
|
396
|
-
// return 0;
|
|
397
|
-
// }
|
|
398
|
-
//
|
|
399
|
-
// return this._enableLoop() ? index + loopClonesPerSide : index;
|
|
400
|
-
// }
|
|
401
|
-
//
|
|
402
|
-
// _getWrappedRef() {
|
|
403
|
-
// if (
|
|
404
|
-
// this._carouselRef &&
|
|
405
|
-
// ((this._needsScrollView() && this._carouselRef.scrollTo) ||
|
|
406
|
-
// (!this._needsScrollView() && this._carouselRef.scrollToOffset))
|
|
407
|
-
// ) {
|
|
408
|
-
// return this._carouselRef;
|
|
409
|
-
// }
|
|
410
|
-
// return (
|
|
411
|
-
// this._carouselRef &&
|
|
412
|
-
// this._carouselRef.getNode &&
|
|
413
|
-
// this._carouselRef.getNode()
|
|
414
|
-
// );
|
|
415
|
-
// }
|
|
416
|
-
//
|
|
417
|
-
// _getScrollEnabled() {
|
|
418
|
-
// return this._scrollEnabled;
|
|
419
|
-
// }
|
|
420
|
-
//
|
|
421
|
-
// _setScrollEnabled(scrollEnabled = true) {
|
|
422
|
-
// const wrappedRef = this._getWrappedRef();
|
|
423
|
-
//
|
|
424
|
-
// if (!wrappedRef || !wrappedRef.setNativeProps) {
|
|
425
|
-
// return;
|
|
426
|
-
// }
|
|
427
|
-
//
|
|
428
|
-
// wrappedRef.setNativeProps({scrollEnabled});
|
|
429
|
-
// this._scrollEnabled = scrollEnabled;
|
|
430
|
-
// }
|
|
431
|
-
//
|
|
432
|
-
// _getItemMainDimension() {
|
|
433
|
-
// return this.props.itemWidth || 20;
|
|
434
|
-
// }
|
|
435
|
-
//
|
|
436
|
-
// _getItemScrollOffset(index: number) {
|
|
437
|
-
// return (
|
|
438
|
-
// this._positions && this._positions[index] && this._positions[index].start
|
|
439
|
-
// );
|
|
440
|
-
// }
|
|
441
|
-
//
|
|
442
|
-
// _getItemLayout(_: any, index: number) {
|
|
443
|
-
// const itemMainDimension = this._getItemMainDimension();
|
|
444
|
-
// return {
|
|
445
|
-
// index,
|
|
446
|
-
// length: itemMainDimension,
|
|
447
|
-
// offset: itemMainDimension * index,
|
|
448
|
-
// };
|
|
449
|
-
// }
|
|
450
|
-
//
|
|
451
|
-
// _getKeyExtractor(_: any, index: any) {
|
|
452
|
-
// return this._needsScrollView()
|
|
453
|
-
// ? `scrollview-item-${index}`
|
|
454
|
-
// : `flatlist-item-${index}`;
|
|
455
|
-
// }
|
|
456
|
-
//
|
|
457
|
-
// _getScrollOffset(event: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
458
|
-
// return event.nativeEvent.contentOffset.x;
|
|
459
|
-
// }
|
|
460
|
-
//
|
|
461
|
-
// _getContainerInnerMargin(opposite = false) {
|
|
462
|
-
// const {
|
|
463
|
-
// activeSlideAlignment,
|
|
464
|
-
// sliderWidth = 100,
|
|
465
|
-
// itemWidth = 20,
|
|
466
|
-
// } = this.props;
|
|
467
|
-
//
|
|
468
|
-
// if (
|
|
469
|
-
// (activeSlideAlignment === 'start' && !opposite) ||
|
|
470
|
-
// (activeSlideAlignment === 'end' && opposite)
|
|
471
|
-
// ) {
|
|
472
|
-
// return 0;
|
|
473
|
-
// } else if (
|
|
474
|
-
// (activeSlideAlignment === 'end' && !opposite) ||
|
|
475
|
-
// (activeSlideAlignment === 'start' && opposite)
|
|
476
|
-
// ) {
|
|
477
|
-
// return sliderWidth - itemWidth;
|
|
478
|
-
// } else {
|
|
479
|
-
// return (sliderWidth - itemWidth) / 2;
|
|
480
|
-
// }
|
|
481
|
-
// }
|
|
482
|
-
//
|
|
483
|
-
// _getActiveSlideOffset() {
|
|
484
|
-
// const {activeSlideOffset} = this.props;
|
|
485
|
-
// const itemMainDimension = this._getItemMainDimension();
|
|
486
|
-
// const minOffset = 10;
|
|
487
|
-
// return itemMainDimension / 2 - activeSlideOffset >= minOffset
|
|
488
|
-
// ? activeSlideOffset
|
|
489
|
-
// : minOffset;
|
|
490
|
-
// }
|
|
491
|
-
//
|
|
492
|
-
// _getActiveItem(offset: number) {
|
|
493
|
-
// const itemMainDimension = this._getItemMainDimension();
|
|
494
|
-
// const center = offset + itemMainDimension / 2;
|
|
495
|
-
// const activeSlideOffset = this._getActiveSlideOffset();
|
|
496
|
-
// const lastIndex = this._positions.length - 1;
|
|
497
|
-
// let itemIndex;
|
|
498
|
-
//
|
|
499
|
-
// if (offset <= 0) {
|
|
500
|
-
// return 0;
|
|
501
|
-
// }
|
|
502
|
-
//
|
|
503
|
-
// if (
|
|
504
|
-
// this._positions[lastIndex] &&
|
|
505
|
-
// offset >= this._positions[lastIndex].start
|
|
506
|
-
// ) {
|
|
507
|
-
// return lastIndex;
|
|
508
|
-
// }
|
|
509
|
-
//
|
|
510
|
-
// for (let i = 0; i < this._positions.length; i++) {
|
|
511
|
-
// const {start, end} = this._positions[i];
|
|
512
|
-
// if (
|
|
513
|
-
// center + activeSlideOffset >= start &&
|
|
514
|
-
// center - activeSlideOffset <= end
|
|
515
|
-
// ) {
|
|
516
|
-
// itemIndex = i;
|
|
517
|
-
// break;
|
|
518
|
-
// }
|
|
519
|
-
// }
|
|
520
|
-
//
|
|
521
|
-
// return itemIndex || 0;
|
|
522
|
-
// }
|
|
523
|
-
//
|
|
524
|
-
// _getSlideInterpolatedStyle(index: number, animatedValue: Animated.Value) {
|
|
525
|
-
// const {slideInterpolatedStyle} = this.props;
|
|
526
|
-
//
|
|
527
|
-
// if (slideInterpolatedStyle) {
|
|
528
|
-
// return slideInterpolatedStyle(index, animatedValue, this.props);
|
|
529
|
-
// } else {
|
|
530
|
-
// return defaultAnimatedStyles(index, animatedValue, this.props);
|
|
531
|
-
// }
|
|
532
|
-
// }
|
|
533
|
-
//
|
|
534
|
-
// _initPositionsAndInterpolators(props = this.props) {
|
|
535
|
-
// const {data, scrollInterpolator} = props;
|
|
536
|
-
// const itemMainDimension = this._getItemMainDimension();
|
|
537
|
-
//
|
|
538
|
-
// if (!data || !data.length) {
|
|
539
|
-
// return;
|
|
540
|
-
// }
|
|
541
|
-
//
|
|
542
|
-
// const interpolators: any[] = [];
|
|
543
|
-
// this._positions = [];
|
|
544
|
-
//
|
|
545
|
-
// this._getCustomData(props).forEach((_itemData, index) => {
|
|
546
|
-
// const _index = this._getCustomIndex(index, props);
|
|
547
|
-
// let animatedValue;
|
|
548
|
-
//
|
|
549
|
-
// this._positions[index] = {
|
|
550
|
-
// start: index * itemMainDimension,
|
|
551
|
-
// end: index * itemMainDimension + itemMainDimension,
|
|
552
|
-
// };
|
|
553
|
-
//
|
|
554
|
-
// if (!this._shouldAnimateSlides(props) || !this._scrollPos) {
|
|
555
|
-
// animatedValue = new Animated.Value(1);
|
|
556
|
-
// } else {
|
|
557
|
-
// let interpolator;
|
|
558
|
-
//
|
|
559
|
-
// if (scrollInterpolator) {
|
|
560
|
-
// interpolator = scrollInterpolator(_index, props);
|
|
561
|
-
// }
|
|
562
|
-
//
|
|
563
|
-
// if (
|
|
564
|
-
// !interpolator ||
|
|
565
|
-
// !interpolator.inputRange ||
|
|
566
|
-
// !interpolator.outputRange
|
|
567
|
-
// ) {
|
|
568
|
-
// interpolator = defaultScrollInterpolator(_index, props);
|
|
569
|
-
// }
|
|
570
|
-
//
|
|
571
|
-
// animatedValue = this._scrollPos.interpolate({
|
|
572
|
-
// ...interpolator,
|
|
573
|
-
// extrapolate: 'clamp',
|
|
574
|
-
// });
|
|
575
|
-
// }
|
|
576
|
-
//
|
|
577
|
-
// interpolators.push(animatedValue);
|
|
578
|
-
// });
|
|
579
|
-
//
|
|
580
|
-
// this.setState({interpolators});
|
|
581
|
-
// }
|
|
582
|
-
//
|
|
583
|
-
// _hackActiveSlideAnimation(index: number, scrollValue = 1) {
|
|
584
|
-
// const offset = this._getItemScrollOffset(index);
|
|
585
|
-
//
|
|
586
|
-
// if (!this._mounted || !this._carouselRef || typeof offset === 'undefined') {
|
|
587
|
-
// return;
|
|
588
|
-
// }
|
|
589
|
-
//
|
|
590
|
-
// const multiplier = this._currentScrollOffset === 0 ? 1 : -1;
|
|
591
|
-
// const scrollDelta = scrollValue * multiplier;
|
|
592
|
-
//
|
|
593
|
-
// this._scrollTo({
|
|
594
|
-
// offset: offset + scrollDelta,
|
|
595
|
-
// animated: false,
|
|
596
|
-
// });
|
|
597
|
-
//
|
|
598
|
-
// clearTimeout(this._hackSlideAnimationTimeout);
|
|
599
|
-
// this._hackSlideAnimationTimeout = setTimeout(() => {
|
|
600
|
-
// this._scrollTo({
|
|
601
|
-
// offset,
|
|
602
|
-
// animated: false,
|
|
603
|
-
// });
|
|
604
|
-
// }, 1);
|
|
605
|
-
// }
|
|
606
|
-
//
|
|
607
|
-
// _repositionScroll(index: number, animated = false) {
|
|
608
|
-
// const {data, loopClonesPerSide} = this.props;
|
|
609
|
-
// const dataLength = data && data.length;
|
|
610
|
-
//
|
|
611
|
-
// if (typeof index === 'undefined' || !this._shouldRepositionScroll(index)) {
|
|
612
|
-
// return;
|
|
613
|
-
// }
|
|
614
|
-
//
|
|
615
|
-
// let repositionTo = index;
|
|
616
|
-
//
|
|
617
|
-
// if (index >= dataLength + loopClonesPerSide) {
|
|
618
|
-
// repositionTo = index - dataLength;
|
|
619
|
-
// } else if (index < loopClonesPerSide) {
|
|
620
|
-
// repositionTo = index + dataLength;
|
|
621
|
-
// }
|
|
622
|
-
//
|
|
623
|
-
// this._snapToItem(repositionTo, animated, false);
|
|
624
|
-
// }
|
|
625
|
-
//
|
|
626
|
-
// _scrollTo(info: {offset?: number; index?: number; animated?: boolean}) {
|
|
627
|
-
// const {offset, index, animated = true} = info;
|
|
628
|
-
// const wrappedRef = this._getWrappedRef();
|
|
629
|
-
// if (
|
|
630
|
-
// !this._mounted ||
|
|
631
|
-
// !wrappedRef ||
|
|
632
|
-
// (typeof offset === 'undefined' && typeof index === 'undefined')
|
|
633
|
-
// ) {
|
|
634
|
-
// return;
|
|
635
|
-
// }
|
|
636
|
-
//
|
|
637
|
-
// let scrollToOffset;
|
|
638
|
-
// if (typeof index !== 'undefined') {
|
|
639
|
-
// scrollToOffset = this._getItemScrollOffset(index);
|
|
640
|
-
// } else {
|
|
641
|
-
// scrollToOffset = offset;
|
|
642
|
-
// }
|
|
643
|
-
//
|
|
644
|
-
// if (typeof scrollToOffset === 'undefined') {
|
|
645
|
-
// return;
|
|
646
|
-
// }
|
|
647
|
-
//
|
|
648
|
-
// const options = this._needsScrollView()
|
|
649
|
-
// ? {
|
|
650
|
-
// x: offset,
|
|
651
|
-
// y: 0,
|
|
652
|
-
// animated,
|
|
653
|
-
// }
|
|
654
|
-
// : {
|
|
655
|
-
// offset,
|
|
656
|
-
// animated,
|
|
657
|
-
// };
|
|
658
|
-
//
|
|
659
|
-
// if (this._needsScrollView()) {
|
|
660
|
-
// wrappedRef.scrollTo(options);
|
|
661
|
-
// } else {
|
|
662
|
-
// wrappedRef.scrollToOffset(options);
|
|
663
|
-
// }
|
|
664
|
-
// }
|
|
665
|
-
//
|
|
666
|
-
// _onTouchStart(event: any) {
|
|
667
|
-
// const {onTouchStart} = this.props;
|
|
668
|
-
//
|
|
669
|
-
// if (this._getScrollEnabled() !== false && this._autoplaying) {
|
|
670
|
-
// this.pauseAutoPlay();
|
|
671
|
-
// }
|
|
672
|
-
//
|
|
673
|
-
// onTouchStart && onTouchStart(event);
|
|
674
|
-
// }
|
|
675
|
-
//
|
|
676
|
-
// _onTouchEnd(event: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
677
|
-
// const {onTouchEnd} = this.props;
|
|
678
|
-
//
|
|
679
|
-
// if (
|
|
680
|
-
// this._getScrollEnabled() !== false &&
|
|
681
|
-
// this._autoplay &&
|
|
682
|
-
// !this._autoplaying
|
|
683
|
-
// ) {
|
|
684
|
-
// this.startAutoplay();
|
|
685
|
-
// }
|
|
686
|
-
//
|
|
687
|
-
// onTouchEnd && onTouchEnd(event);
|
|
688
|
-
// }
|
|
689
|
-
//
|
|
690
|
-
// _onScroll(event: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
691
|
-
// const {onScroll, onScrollIndexChanged, onSnapToItem} = this.props;
|
|
692
|
-
// const scrollOffset = event
|
|
693
|
-
// ? this._getScrollOffset(event)
|
|
694
|
-
// : this._currentScrollOffset;
|
|
695
|
-
// const nextActiveItem = this._getActiveItem(scrollOffset);
|
|
696
|
-
// const dataLength = this._getCustomDataLength();
|
|
697
|
-
// const lastItemScrollOffset = this._getItemScrollOffset(dataLength - 1);
|
|
698
|
-
//
|
|
699
|
-
// this._currentScrollOffset = scrollOffset;
|
|
700
|
-
//
|
|
701
|
-
// if (nextActiveItem !== this._onScrollActiveItem) {
|
|
702
|
-
// this._onScrollActiveItem = nextActiveItem;
|
|
703
|
-
// onScrollIndexChanged &&
|
|
704
|
-
// onScrollIndexChanged(this._getDataIndex(nextActiveItem));
|
|
705
|
-
//
|
|
706
|
-
// onSnapToItem && onSnapToItem(this._getDataIndex(nextActiveItem));
|
|
707
|
-
// }
|
|
708
|
-
//
|
|
709
|
-
// if (
|
|
710
|
-
// (IS_IOS && scrollOffset > lastItemScrollOffset) ||
|
|
711
|
-
// (IS_ANDROID &&
|
|
712
|
-
// Math.floor(scrollOffset) > Math.floor(lastItemScrollOffset))
|
|
713
|
-
// ) {
|
|
714
|
-
// this._activeItem = nextActiveItem;
|
|
715
|
-
// this._repositionScroll(nextActiveItem);
|
|
716
|
-
// }
|
|
717
|
-
//
|
|
718
|
-
// if (typeof onScroll === 'function' && event) {
|
|
719
|
-
// onScroll(event);
|
|
720
|
-
// }
|
|
721
|
-
// }
|
|
722
|
-
//
|
|
723
|
-
// _onMomentumScrollEnd(event: NativeSyntheticEvent<NativeScrollEvent>) {
|
|
724
|
-
// const {
|
|
725
|
-
// autoplayDelay,
|
|
726
|
-
// onMomentumScrollEnd,
|
|
727
|
-
// onSnapToItem,
|
|
728
|
-
// itemWidth = 20,
|
|
729
|
-
// } = this.props;
|
|
730
|
-
// const scrollOffset = event
|
|
731
|
-
// ? this._getScrollOffset(event)
|
|
732
|
-
// : this._currentScrollOffset;
|
|
733
|
-
// const nextActiveItem = this._getActiveItem(scrollOffset);
|
|
734
|
-
// const hasSnapped = this._isMultiple(scrollOffset, itemWidth || 20);
|
|
735
|
-
//
|
|
736
|
-
// if (nextActiveItem !== this._activeItem) {
|
|
737
|
-
// this._activeItem = nextActiveItem;
|
|
738
|
-
// onSnapToItem && onSnapToItem(this._getDataIndex(nextActiveItem));
|
|
739
|
-
//
|
|
740
|
-
// if (hasSnapped && IS_ANDROID) {
|
|
741
|
-
// this._repositionScroll(nextActiveItem);
|
|
742
|
-
// } else if (IS_IOS) {
|
|
743
|
-
// this._repositionScroll(nextActiveItem);
|
|
744
|
-
// }
|
|
745
|
-
// }
|
|
746
|
-
//
|
|
747
|
-
// onMomentumScrollEnd && onMomentumScrollEnd(event);
|
|
748
|
-
//
|
|
749
|
-
// if (IS_ANDROID && this._autoplay && !this._autoplaying) {
|
|
750
|
-
// clearTimeout(this._enableAutoplayTimeout);
|
|
751
|
-
// this._enableAutoplayTimeout = setTimeout(() => {
|
|
752
|
-
// this.startAutoplay();
|
|
753
|
-
// }, autoplayDelay);
|
|
754
|
-
// }
|
|
755
|
-
// }
|
|
756
|
-
//
|
|
757
|
-
// _onLayout(event: LayoutChangeEvent) {
|
|
758
|
-
// const {onLayout} = this.props;
|
|
759
|
-
//
|
|
760
|
-
// if (this._onLayoutInitDone) {
|
|
761
|
-
// this._initPositionsAndInterpolators();
|
|
762
|
-
// this._snapToItem(this._activeItem, false, false, true);
|
|
763
|
-
// } else {
|
|
764
|
-
// this._onLayoutInitDone = true;
|
|
765
|
-
// }
|
|
766
|
-
//
|
|
767
|
-
// onLayout && onLayout(event);
|
|
768
|
-
// }
|
|
769
|
-
//
|
|
770
|
-
// _snapToItem(
|
|
771
|
-
// index: number,
|
|
772
|
-
// animated = true,
|
|
773
|
-
// fireCallback = true,
|
|
774
|
-
// forceScrollTo = false,
|
|
775
|
-
// ) {
|
|
776
|
-
// const {onSnapToItem} = this.props;
|
|
777
|
-
// const itemsLength = this._getCustomDataLength();
|
|
778
|
-
// const wrappedRef = this._getWrappedRef();
|
|
779
|
-
// if (!itemsLength || !wrappedRef) {
|
|
780
|
-
// return;
|
|
781
|
-
// }
|
|
782
|
-
//
|
|
783
|
-
// if (!index || index < 0) {
|
|
784
|
-
// index = 0;
|
|
785
|
-
// } else if (itemsLength > 0 && index >= itemsLength) {
|
|
786
|
-
// index = itemsLength - 1;
|
|
787
|
-
// }
|
|
788
|
-
//
|
|
789
|
-
// if (index === this._activeItem && !forceScrollTo) {
|
|
790
|
-
// return;
|
|
791
|
-
// }
|
|
792
|
-
//
|
|
793
|
-
// const offset = this._getItemScrollOffset(index);
|
|
794
|
-
//
|
|
795
|
-
// if (offset === undefined) {
|
|
796
|
-
// return;
|
|
797
|
-
// }
|
|
798
|
-
//
|
|
799
|
-
// this._scrollTo({
|
|
800
|
-
// offset,
|
|
801
|
-
// animated,
|
|
802
|
-
// });
|
|
803
|
-
//
|
|
804
|
-
// const requiresManualTrigger = !animated || IS_ANDROID;
|
|
805
|
-
// if (requiresManualTrigger) {
|
|
806
|
-
// this._activeItem = index;
|
|
807
|
-
//
|
|
808
|
-
// if (fireCallback) {
|
|
809
|
-
// onSnapToItem && onSnapToItem(this._getDataIndex(index));
|
|
810
|
-
// }
|
|
811
|
-
//
|
|
812
|
-
// if (IS_ANDROID && this._shouldRepositionScroll(index)) {
|
|
813
|
-
// if (animated) {
|
|
814
|
-
// this._androidRepositioningTimeout = setTimeout(() => {
|
|
815
|
-
// this._repositionScroll(index, false);
|
|
816
|
-
// }, 400);
|
|
817
|
-
// } else {
|
|
818
|
-
// this._repositionScroll(index);
|
|
819
|
-
// }
|
|
820
|
-
// }
|
|
821
|
-
// }
|
|
822
|
-
// }
|
|
823
|
-
//
|
|
824
|
-
// startAutoplay() {
|
|
825
|
-
// const {autoplayInterval, autoplayDelay} = this.props;
|
|
826
|
-
// this._autoplay = true;
|
|
827
|
-
//
|
|
828
|
-
// if (this._autoplaying) {
|
|
829
|
-
// return;
|
|
830
|
-
// }
|
|
831
|
-
//
|
|
832
|
-
// clearTimeout(this._autoplayTimeout);
|
|
833
|
-
// this._autoplayTimeout = setTimeout(() => {
|
|
834
|
-
// this._autoplaying = true;
|
|
835
|
-
// this._autoplayInterval = setInterval(() => {
|
|
836
|
-
// if (this._autoplaying) {
|
|
837
|
-
// this.snapToNext();
|
|
838
|
-
// }
|
|
839
|
-
// }, autoplayInterval);
|
|
840
|
-
// }, autoplayDelay);
|
|
841
|
-
// }
|
|
842
|
-
//
|
|
843
|
-
// pauseAutoPlay() {
|
|
844
|
-
// this._autoplaying = false;
|
|
845
|
-
// clearTimeout(this._autoplayTimeout);
|
|
846
|
-
// clearTimeout(this._enableAutoplayTimeout);
|
|
847
|
-
// clearInterval(this._autoplayInterval);
|
|
848
|
-
// }
|
|
849
|
-
//
|
|
850
|
-
// stopAutoplay() {
|
|
851
|
-
// this._autoplay = false;
|
|
852
|
-
// this.pauseAutoPlay();
|
|
853
|
-
// }
|
|
854
|
-
//
|
|
855
|
-
// snapToNext(animated = true, fireCallback = true) {
|
|
856
|
-
// const itemsLength = this._getCustomDataLength();
|
|
857
|
-
//
|
|
858
|
-
// let newIndex = this._activeItem + 1;
|
|
859
|
-
// if (newIndex > itemsLength - 1) {
|
|
860
|
-
// newIndex = 0;
|
|
861
|
-
// }
|
|
862
|
-
// this._snapToItem(newIndex, animated, fireCallback);
|
|
863
|
-
// }
|
|
864
|
-
//
|
|
865
|
-
// snapToPrev(animated = true, fireCallback = true) {
|
|
866
|
-
// const itemsLength = this._getCustomDataLength();
|
|
867
|
-
//
|
|
868
|
-
// let newIndex = this._activeItem - 1;
|
|
869
|
-
// if (newIndex < 0) {
|
|
870
|
-
// newIndex = itemsLength - 1;
|
|
871
|
-
// }
|
|
872
|
-
// this._snapToItem(newIndex, animated, fireCallback);
|
|
873
|
-
// }
|
|
874
|
-
//
|
|
875
|
-
// triggerRenderingHack(offset = 1) {
|
|
876
|
-
// this._hackActiveSlideAnimation(this._activeItem, offset);
|
|
877
|
-
// }
|
|
878
|
-
//
|
|
879
|
-
// _renderItem(info: {item: any; index: number}) {
|
|
880
|
-
// const {item, index} = info;
|
|
881
|
-
// const {interpolators} = this.state;
|
|
882
|
-
// const {keyExtractor, slideStyle} = this.props;
|
|
883
|
-
// const animatedValue = interpolators && interpolators[index];
|
|
884
|
-
//
|
|
885
|
-
// if (typeof animatedValue === 'undefined') {
|
|
886
|
-
// return null;
|
|
887
|
-
// }
|
|
888
|
-
//
|
|
889
|
-
// const animate = this._shouldAnimateSlides();
|
|
890
|
-
// const Component = animate ? Animated.View : View;
|
|
891
|
-
// const animatedStyle = animate
|
|
892
|
-
// ? this._getSlideInterpolatedStyle(index, animatedValue)
|
|
893
|
-
// : {};
|
|
894
|
-
//
|
|
895
|
-
// const mainDimension = {width: this.props.itemWidth};
|
|
896
|
-
// const specificProps = this._needsScrollView()
|
|
897
|
-
// ? {
|
|
898
|
-
// key: keyExtractor
|
|
899
|
-
// ? keyExtractor(item, index)
|
|
900
|
-
// : this._getKeyExtractor(item, index),
|
|
901
|
-
// }
|
|
902
|
-
// : {};
|
|
903
|
-
//
|
|
904
|
-
// return (
|
|
905
|
-
// <Component
|
|
906
|
-
// style={[mainDimension, slideStyle, animatedStyle]}
|
|
907
|
-
// pointerEvents="box-none"
|
|
908
|
-
// {...specificProps}>
|
|
909
|
-
// {this.props.renderItem({
|
|
910
|
-
// item,
|
|
911
|
-
// index,
|
|
912
|
-
// })}
|
|
913
|
-
// </Component>
|
|
914
|
-
// );
|
|
915
|
-
// }
|
|
916
|
-
//
|
|
917
|
-
// _getComponentOverridableProps() {
|
|
918
|
-
// const {hideCarousel} = this.state;
|
|
919
|
-
// const {loopClonesPerSide, sliderWidth = 100, itemWidth = 20} = this.props;
|
|
920
|
-
// const visibleItems = Math.ceil(sliderWidth / itemWidth) + 1;
|
|
921
|
-
// const initialNumPerSide = this._enableLoop() ? loopClonesPerSide : 2;
|
|
922
|
-
// const initialNumToRender =
|
|
923
|
-
// visibleItems > 2
|
|
924
|
-
// ? visibleItems + initialNumPerSide * 2
|
|
925
|
-
// : initialNumPerSide * 2;
|
|
926
|
-
// const maxToRenderPerBatch = initialNumToRender;
|
|
927
|
-
// const windowSize = maxToRenderPerBatch;
|
|
928
|
-
// const specificProps = !this._needsScrollView()
|
|
929
|
-
// ? {
|
|
930
|
-
// initialNumToRender,
|
|
931
|
-
// maxToRenderPerBatch,
|
|
932
|
-
// windowSize,
|
|
933
|
-
// }
|
|
934
|
-
// : {};
|
|
935
|
-
//
|
|
936
|
-
// return {
|
|
937
|
-
// ...specificProps,
|
|
938
|
-
// automaticallyAdjustContentInsets: false,
|
|
939
|
-
// decelerationRate: 'fast',
|
|
940
|
-
// directionalLockEnabled: true,
|
|
941
|
-
// disableScrollViewPanResponder: false, // If set to `true`, touch events will be triggered too easily
|
|
942
|
-
// inverted: this._needsRTLAdaptations(),
|
|
943
|
-
// overScrollMode: 'never',
|
|
944
|
-
// pinchGestureEnabled: false,
|
|
945
|
-
// pointerEvents: hideCarousel ? 'none' : 'auto',
|
|
946
|
-
// scrollsToTop: false,
|
|
947
|
-
// showsHorizontalScrollIndicator: false,
|
|
948
|
-
// showsVerticalScrollIndicator: false,
|
|
949
|
-
// };
|
|
950
|
-
// }
|
|
951
|
-
//
|
|
952
|
-
// _getComponentStaticProps() {
|
|
953
|
-
// const {hideCarousel} = this.state;
|
|
954
|
-
// const {
|
|
955
|
-
// activeSlideAlignment,
|
|
956
|
-
// containerCustomStyle,
|
|
957
|
-
// contentContainerCustomStyle,
|
|
958
|
-
// firstItem,
|
|
959
|
-
// getItemLayout,
|
|
960
|
-
// keyExtractor,
|
|
961
|
-
// style,
|
|
962
|
-
// useExperimentalSnap,
|
|
963
|
-
// disableIntervalMomentum,
|
|
964
|
-
// enableSnap,
|
|
965
|
-
// } = this.props;
|
|
966
|
-
// const containerStyle = [
|
|
967
|
-
// containerCustomStyle || style || {},
|
|
968
|
-
// hideCarousel ? {opacity: 0} : {},
|
|
969
|
-
// {
|
|
970
|
-
// width: this.props.sliderWidth,
|
|
971
|
-
// flexDirection: this._needsRTLAdaptations() ? 'row-reverse' : 'row',
|
|
972
|
-
// },
|
|
973
|
-
// ];
|
|
974
|
-
//
|
|
975
|
-
// const contentContainerStyle = [
|
|
976
|
-
// {
|
|
977
|
-
// paddingLeft: this._getContainerInnerMargin(),
|
|
978
|
-
// paddingRight: this._getContainerInnerMargin(true),
|
|
979
|
-
// },
|
|
980
|
-
// contentContainerCustomStyle || {},
|
|
981
|
-
// ];
|
|
982
|
-
//
|
|
983
|
-
// const snapProps =
|
|
984
|
-
// enableSnap && useExperimentalSnap
|
|
985
|
-
// ? {
|
|
986
|
-
// disableIntervalMomentum, // Slide ± one item at a time
|
|
987
|
-
// snapToAlignment: activeSlideAlignment,
|
|
988
|
-
// snapToInterval: this._getItemMainDimension(),
|
|
989
|
-
// }
|
|
990
|
-
// : {
|
|
991
|
-
// snapToOffsets: this._getSnapOffsets(),
|
|
992
|
-
// };
|
|
993
|
-
//
|
|
994
|
-
// const specificProps = !this._needsScrollView()
|
|
995
|
-
// ? {
|
|
996
|
-
// getItemLayout: getItemLayout || this._getItemLayout,
|
|
997
|
-
// initialScrollIndex: this._getFirstItem(firstItem),
|
|
998
|
-
// keyExtractor: keyExtractor || this._getKeyExtractor,
|
|
999
|
-
// numColumns: 1,
|
|
1000
|
-
// renderItem: this._renderItem,
|
|
1001
|
-
// }
|
|
1002
|
-
// : {};
|
|
1003
|
-
//
|
|
1004
|
-
// return {
|
|
1005
|
-
// ...specificProps,
|
|
1006
|
-
// ...snapProps,
|
|
1007
|
-
// ref: (
|
|
1008
|
-
// c: {scrollTo: any; scrollToOffset: any; getNode: () => any} | undefined,
|
|
1009
|
-
// ) => {
|
|
1010
|
-
// this._carouselRef = c;
|
|
1011
|
-
// },
|
|
1012
|
-
// contentContainerStyle: contentContainerStyle,
|
|
1013
|
-
// data: this._getCustomData(),
|
|
1014
|
-
// horizontal: true,
|
|
1015
|
-
// scrollEventThrottle: 1,
|
|
1016
|
-
// style: containerStyle,
|
|
1017
|
-
// onLayout: this._onLayout,
|
|
1018
|
-
// onMomentumScrollEnd: this._onMomentumScrollEnd,
|
|
1019
|
-
// onScroll: this._onScrollHandler,
|
|
1020
|
-
// onTouchStart: this._onTouchStart,
|
|
1021
|
-
// onTouchEnd: this._onTouchEnd,
|
|
1022
|
-
// };
|
|
1023
|
-
// }
|
|
1024
|
-
//
|
|
1025
|
-
// render() {
|
|
1026
|
-
// const {data, renderItem, useScrollView} = this.props;
|
|
1027
|
-
// if (!data || !renderItem) {
|
|
1028
|
-
// return null;
|
|
1029
|
-
// }
|
|
1030
|
-
//
|
|
1031
|
-
// console.log(data);
|
|
1032
|
-
//
|
|
1033
|
-
// const props = {
|
|
1034
|
-
// ...this._getComponentOverridableProps(),
|
|
1035
|
-
// ...this.props,
|
|
1036
|
-
// ...this._getComponentStaticProps(),
|
|
1037
|
-
// };
|
|
1038
|
-
//
|
|
1039
|
-
// return <Animated.FlatList {...props} />;
|
|
1040
|
-
// }
|
|
1041
|
-
// }
|