react-slideshow-image 4.2.1 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/helpers.d.ts +2 -2
- package/dist/react-slideshow-image.cjs.development.js +75 -156
- package/dist/react-slideshow-image.cjs.development.js.map +1 -1
- package/dist/react-slideshow-image.cjs.production.min.js +1 -1
- package/dist/react-slideshow-image.cjs.production.min.js.map +1 -1
- package/dist/react-slideshow-image.esm.js +75 -156
- package/dist/react-slideshow-image.esm.js.map +1 -1
- package/dist/slide.d.ts +1 -1
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +6 -2
@@ -13,14 +13,12 @@ function _extends() {
|
|
13
13
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
14
14
|
for (var i = 1; i < arguments.length; i++) {
|
15
15
|
var source = arguments[i];
|
16
|
-
|
17
16
|
for (var key in source) {
|
18
17
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
19
18
|
target[key] = source[key];
|
20
19
|
}
|
21
20
|
}
|
22
21
|
}
|
23
|
-
|
24
22
|
return target;
|
25
23
|
};
|
26
24
|
return _extends.apply(this, arguments);
|
@@ -30,7 +28,6 @@ var getStartingIndex = function getStartingIndex(children, defaultIndex) {
|
|
30
28
|
if (defaultIndex && defaultIndex < React__default.Children.count(children)) {
|
31
29
|
return defaultIndex;
|
32
30
|
}
|
33
|
-
|
34
31
|
return 0;
|
35
32
|
};
|
36
33
|
var getResponsiveSettings = function getResponsiveSettings(wrapperWidth, responsive) {
|
@@ -39,7 +36,6 @@ var getResponsiveSettings = function getResponsiveSettings(wrapperWidth, respons
|
|
39
36
|
return each.breakpoint <= wrapperWidth;
|
40
37
|
});
|
41
38
|
}
|
42
|
-
|
43
39
|
return;
|
44
40
|
};
|
45
41
|
var EASING_METHODS = {
|
@@ -55,12 +51,11 @@ var getEasing = function getEasing(easeMethod) {
|
|
55
51
|
if (easeMethod) {
|
56
52
|
return EASING_METHODS[easeMethod];
|
57
53
|
}
|
58
|
-
|
59
54
|
return EASING_METHODS.linear;
|
60
55
|
};
|
61
56
|
var showPreviousArrow = function showPreviousArrow(_ref, currentIndex, moveSlides) {
|
62
57
|
var prevArrow = _ref.prevArrow,
|
63
|
-
|
58
|
+
infinite = _ref.infinite;
|
64
59
|
var isDisabled = currentIndex <= 0 && !infinite;
|
65
60
|
var props = {
|
66
61
|
'data-type': 'prev',
|
@@ -68,13 +63,11 @@ var showPreviousArrow = function showPreviousArrow(_ref, currentIndex, moveSlide
|
|
68
63
|
disabled: isDisabled,
|
69
64
|
onClick: moveSlides
|
70
65
|
};
|
71
|
-
|
72
66
|
if (prevArrow) {
|
73
67
|
return /*#__PURE__*/React__default.cloneElement(prevArrow, _extends({
|
74
68
|
className: (prevArrow.props.className || '') + " nav " + (isDisabled ? 'disabled' : '')
|
75
69
|
}, props));
|
76
70
|
}
|
77
|
-
|
78
71
|
var className = "nav default-nav " + (isDisabled ? 'disabled' : '');
|
79
72
|
return /*#__PURE__*/React__default.createElement("button", Object.assign({
|
80
73
|
type: "button",
|
@@ -89,14 +82,12 @@ var showPreviousArrow = function showPreviousArrow(_ref, currentIndex, moveSlide
|
|
89
82
|
};
|
90
83
|
var showNextArrow = function showNextArrow(properties, currentIndex, moveSlides) {
|
91
84
|
var nextArrow = properties.nextArrow,
|
92
|
-
|
93
|
-
|
85
|
+
infinite = properties.infinite,
|
86
|
+
children = properties.children;
|
94
87
|
var slidesToScroll = 1;
|
95
|
-
|
96
88
|
if ('slidesToScroll' in properties) {
|
97
89
|
slidesToScroll = properties.slidesToScroll || 1;
|
98
90
|
}
|
99
|
-
|
100
91
|
var isDisabled = currentIndex >= React__default.Children.count(children) - slidesToScroll && !infinite;
|
101
92
|
var props = {
|
102
93
|
'data-type': 'next',
|
@@ -104,13 +95,11 @@ var showNextArrow = function showNextArrow(properties, currentIndex, moveSlides)
|
|
104
95
|
disabled: isDisabled,
|
105
96
|
onClick: moveSlides
|
106
97
|
};
|
107
|
-
|
108
98
|
if (nextArrow) {
|
109
99
|
return /*#__PURE__*/React__default.cloneElement(nextArrow, _extends({
|
110
100
|
className: (nextArrow.props.className || '') + " nav " + (isDisabled ? 'disabled' : '')
|
111
101
|
}, props));
|
112
102
|
}
|
113
|
-
|
114
103
|
var className = "nav default-nav " + (isDisabled ? 'disabled' : '');
|
115
104
|
return /*#__PURE__*/React__default.createElement("button", Object.assign({
|
116
105
|
type: "button",
|
@@ -123,7 +112,6 @@ var showNextArrow = function showNextArrow(properties, currentIndex, moveSlides)
|
|
123
112
|
d: "M5 3l3.057-3 11.943 12-11.943 12-3.057-3 9-9z"
|
124
113
|
})));
|
125
114
|
};
|
126
|
-
|
127
115
|
var showDefaultIndicator = function showDefaultIndicator(isCurrentPageActive, key, indicatorProps) {
|
128
116
|
return /*#__PURE__*/React__default.createElement("li", {
|
129
117
|
key: key
|
@@ -132,25 +120,21 @@ var showDefaultIndicator = function showDefaultIndicator(isCurrentPageActive, ke
|
|
132
120
|
className: "each-slideshow-indicator " + (isCurrentPageActive ? 'active' : '')
|
133
121
|
}, indicatorProps)));
|
134
122
|
};
|
135
|
-
|
136
123
|
var showCustomIndicator = function showCustomIndicator(isCurrentPageActive, key, indicatorProps, eachIndicator) {
|
137
124
|
return /*#__PURE__*/React__default.cloneElement(eachIndicator, _extends({
|
138
125
|
className: eachIndicator.props.className + " " + (isCurrentPageActive ? 'active' : ''),
|
139
126
|
key: key
|
140
127
|
}, indicatorProps));
|
141
128
|
};
|
142
|
-
|
143
129
|
var showIndicators = function showIndicators(props, currentIndex, navigate, responsiveSettings) {
|
144
130
|
var children = props.children,
|
145
|
-
|
131
|
+
indicators = props.indicators;
|
146
132
|
var slidesToScroll = 1;
|
147
|
-
|
148
133
|
if (responsiveSettings) {
|
149
134
|
slidesToScroll = responsiveSettings == null ? void 0 : responsiveSettings.settings.slidesToScroll;
|
150
135
|
} else if ('slidesToScroll' in props) {
|
151
136
|
slidesToScroll = props.slidesToScroll || 1;
|
152
137
|
}
|
153
|
-
|
154
138
|
var pages = Math.ceil(React__default.Children.count(children) / slidesToScroll);
|
155
139
|
return /*#__PURE__*/React__default.createElement("ul", {
|
156
140
|
className: "indicators"
|
@@ -163,11 +147,9 @@ var showIndicators = function showIndicators(props, currentIndex, navigate, resp
|
|
163
147
|
onClick: navigate
|
164
148
|
};
|
165
149
|
var isCurrentPageActive = Math.floor((currentIndex + slidesToScroll - 1) / slidesToScroll) === key;
|
166
|
-
|
167
150
|
if (typeof indicators === 'function') {
|
168
151
|
return showCustomIndicator(isCurrentPageActive, key, indicatorProps, indicators(key));
|
169
152
|
}
|
170
|
-
|
171
153
|
return showDefaultIndicator(isCurrentPageActive, key, indicatorProps);
|
172
154
|
}));
|
173
155
|
};
|
@@ -189,9 +171,8 @@ var defaultProps = {
|
|
189
171
|
|
190
172
|
var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
191
173
|
var _useState = React.useState(getStartingIndex(props.children, props.defaultIndex)),
|
192
|
-
|
193
|
-
|
194
|
-
|
174
|
+
index = _useState[0],
|
175
|
+
setIndex = _useState[1];
|
195
176
|
var wrapperRef = React.useRef(null);
|
196
177
|
var innerWrapperRef = React.useRef(null);
|
197
178
|
var tweenGroup = React.useRef(new tween_js.Group());
|
@@ -205,10 +186,8 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
205
186
|
var wrapperWidth = wrapperRef.current.clientWidth;
|
206
187
|
var fullwidth = wrapperWidth * childrenCount;
|
207
188
|
innerWrapperRef.current.style.width = fullwidth + "px";
|
208
|
-
|
209
189
|
for (var _index = 0; _index < innerWrapperRef.current.children.length; _index++) {
|
210
190
|
var eachDiv = innerWrapperRef.current.children[_index];
|
211
|
-
|
212
191
|
if (eachDiv) {
|
213
192
|
eachDiv.style.width = wrapperWidth + "px";
|
214
193
|
eachDiv.style.left = _index * -wrapperWidth + "px";
|
@@ -228,14 +207,13 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
228
207
|
}, [wrapperRef, applyStyle]);
|
229
208
|
var play = React.useCallback(function () {
|
230
209
|
var autoplay = props.autoplay,
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
210
|
+
children = props.children,
|
211
|
+
duration = props.duration,
|
212
|
+
infinite = props.infinite;
|
235
213
|
if (autoplay && React__default.Children.count(children) > 1 && (infinite || index < React__default.Children.count(children) - 1)) {
|
236
214
|
timeout.current = setTimeout(moveNext, duration);
|
237
|
-
}
|
238
|
-
|
215
|
+
}
|
216
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
239
217
|
}, [props, index]);
|
240
218
|
React.useEffect(function () {
|
241
219
|
initResizeObserver();
|
@@ -269,78 +247,61 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
269
247
|
}
|
270
248
|
};
|
271
249
|
});
|
272
|
-
|
273
250
|
var removeResizeObserver = function removeResizeObserver() {
|
274
251
|
if (resizeObserver.current && wrapperRef.current) {
|
275
252
|
resizeObserver.current.unobserve(wrapperRef.current);
|
276
253
|
}
|
277
254
|
};
|
278
|
-
|
279
255
|
var pauseSlides = function pauseSlides() {
|
280
256
|
if (props.pauseOnHover) {
|
281
257
|
clearTimeout(timeout.current);
|
282
258
|
}
|
283
259
|
};
|
284
|
-
|
285
260
|
var startSlides = function startSlides() {
|
286
261
|
var pauseOnHover = props.pauseOnHover,
|
287
|
-
|
288
|
-
|
289
|
-
|
262
|
+
autoplay = props.autoplay,
|
263
|
+
duration = props.duration;
|
290
264
|
if (pauseOnHover && autoplay) {
|
291
265
|
timeout.current = setTimeout(function () {
|
292
266
|
return moveNext();
|
293
267
|
}, duration);
|
294
268
|
}
|
295
269
|
};
|
296
|
-
|
297
270
|
var moveNext = function moveNext() {
|
298
271
|
var children = props.children,
|
299
|
-
|
300
|
-
|
272
|
+
infinite = props.infinite;
|
301
273
|
if (!infinite && index === React__default.Children.count(children) - 1) {
|
302
274
|
return;
|
303
275
|
}
|
304
|
-
|
305
276
|
transitionSlide((index + 1) % React__default.Children.count(children));
|
306
277
|
};
|
307
|
-
|
308
278
|
var moveBack = function moveBack() {
|
309
279
|
var children = props.children,
|
310
|
-
|
311
|
-
|
280
|
+
infinite = props.infinite;
|
312
281
|
if (!infinite && index === 0) {
|
313
282
|
return;
|
314
283
|
}
|
315
|
-
|
316
284
|
transitionSlide(index === 0 ? React__default.Children.count(children) - 1 : index - 1);
|
317
285
|
};
|
318
|
-
|
319
286
|
var preTransition = function preTransition(event) {
|
320
287
|
var currentTarget = event.currentTarget;
|
321
|
-
|
322
288
|
if (currentTarget.dataset.type === 'prev') {
|
323
289
|
moveBack();
|
324
290
|
} else {
|
325
291
|
moveNext();
|
326
292
|
}
|
327
293
|
};
|
328
|
-
|
329
294
|
var animate = function animate() {
|
330
295
|
requestAnimationFrame(animate);
|
331
296
|
tweenGroup.current.update();
|
332
297
|
};
|
333
|
-
|
334
298
|
var transitionSlide = function transitionSlide(newIndex) {
|
335
299
|
var existingTweens = tweenGroup.current.getAll();
|
336
|
-
|
337
300
|
if (!existingTweens.length) {
|
338
301
|
var _innerWrapperRef$curr;
|
339
|
-
|
340
302
|
if (!((_innerWrapperRef$curr = innerWrapperRef.current) != null && _innerWrapperRef$curr.children[newIndex])) {
|
341
303
|
newIndex = 0;
|
342
304
|
}
|
343
|
-
|
344
305
|
clearTimeout(timeout.current);
|
345
306
|
var value = {
|
346
307
|
opacity: 0,
|
@@ -354,7 +315,6 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
354
315
|
if (!innerWrapperRef.current) {
|
355
316
|
return;
|
356
317
|
}
|
357
|
-
|
358
318
|
innerWrapperRef.current.children[newIndex].style.opacity = value.opacity;
|
359
319
|
innerWrapperRef.current.children[index].style.opacity = 1 - value.opacity;
|
360
320
|
innerWrapperRef.current.children[index].style.transform = "scale(" + value.scale + ")";
|
@@ -370,7 +330,6 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
370
330
|
setIndex(newIndex);
|
371
331
|
innerWrapperRef.current.children[index].style.transform = "scale(1)";
|
372
332
|
}
|
373
|
-
|
374
333
|
if (typeof props.onChange === 'function') {
|
375
334
|
props.onChange(index, newIndex);
|
376
335
|
}
|
@@ -378,25 +337,20 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
378
337
|
tween.start();
|
379
338
|
}
|
380
339
|
};
|
381
|
-
|
382
340
|
var moveTo = function moveTo(gotoIndex) {
|
383
341
|
if (gotoIndex !== index) {
|
384
342
|
transitionSlide(gotoIndex);
|
385
343
|
}
|
386
344
|
};
|
387
|
-
|
388
345
|
var navigate = function navigate(event) {
|
389
346
|
var currentTarget = event.currentTarget;
|
390
|
-
|
391
347
|
if (!currentTarget.dataset.key) {
|
392
348
|
return;
|
393
349
|
}
|
394
|
-
|
395
350
|
if (parseInt(currentTarget.dataset.key) !== index) {
|
396
351
|
moveTo(parseInt(currentTarget.dataset.key));
|
397
352
|
}
|
398
353
|
};
|
399
|
-
|
400
354
|
return /*#__PURE__*/React__default.createElement("div", {
|
401
355
|
dir: "ltr",
|
402
356
|
"aria-roledescription": "carousel"
|
@@ -445,81 +399,83 @@ Zoom.defaultProps = defaultProps;
|
|
445
399
|
|
446
400
|
var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
447
401
|
var _useState = React.useState(getStartingIndex(props.children, props.defaultIndex)),
|
448
|
-
|
449
|
-
|
450
|
-
|
402
|
+
index = _useState[0],
|
403
|
+
setIndex = _useState[1];
|
451
404
|
var _useState2 = React.useState(0),
|
452
|
-
|
453
|
-
|
454
|
-
|
405
|
+
wrapperSize = _useState2[0],
|
406
|
+
setWrapperSize = _useState2[1];
|
455
407
|
var wrapperRef = React.useRef(null);
|
456
408
|
var innerWrapperRef = React.useRef(null);
|
457
409
|
var tweenGroup = React.useRef(new tween_js.Group());
|
458
410
|
var responsiveSettings = React.useMemo(function () {
|
459
|
-
return getResponsiveSettings(
|
460
|
-
}, [
|
411
|
+
return getResponsiveSettings(wrapperSize, props.responsive);
|
412
|
+
}, [wrapperSize, props.responsive]);
|
461
413
|
var slidesToScroll = React.useMemo(function () {
|
462
414
|
if (responsiveSettings) {
|
463
415
|
return responsiveSettings.settings.slidesToScroll;
|
464
416
|
}
|
465
|
-
|
466
417
|
return props.slidesToScroll || 1;
|
467
418
|
}, [responsiveSettings, props.slidesToScroll]);
|
468
419
|
var slidesToShow = React.useMemo(function () {
|
469
420
|
if (responsiveSettings) {
|
470
421
|
return responsiveSettings.settings.slidesToShow;
|
471
422
|
}
|
472
|
-
|
473
423
|
return props.slidesToShow || 1;
|
474
424
|
}, [responsiveSettings, props.slidesToShow]);
|
475
425
|
var childrenCount = React.useMemo(function () {
|
476
426
|
return React__default.Children.count(props.children);
|
477
427
|
}, [props.children]);
|
478
|
-
var
|
479
|
-
return
|
480
|
-
}, [
|
428
|
+
var eachChildSize = React.useMemo(function () {
|
429
|
+
return wrapperSize / slidesToShow;
|
430
|
+
}, [wrapperSize, slidesToShow]);
|
481
431
|
var timeout = React.useRef();
|
482
432
|
var resizeObserver = React.useRef();
|
483
|
-
var
|
433
|
+
var startingSwipePosition;
|
484
434
|
var dragging = false;
|
485
435
|
var distanceSwiped = 0;
|
436
|
+
var translateType = props.vertical ? 'translateY' : 'translateX';
|
437
|
+
var swipeAttributeType = props.vertical ? 'clientY' : 'clientX';
|
438
|
+
var swipePageAttributeType = props.vertical ? 'pageY' : 'pageX';
|
486
439
|
var applyStyle = React.useCallback(function () {
|
487
440
|
if (innerWrapperRef.current) {
|
488
|
-
var
|
489
|
-
|
490
|
-
|
441
|
+
var fullSize = wrapperSize * innerWrapperRef.current.children.length;
|
442
|
+
var attribute = props.vertical ? 'height' : 'width';
|
443
|
+
innerWrapperRef.current.style[attribute] = fullSize + "px";
|
444
|
+
if (props.vertical && wrapperRef.current) {
|
445
|
+
wrapperRef.current.style[attribute] = wrapperSize + "px";
|
446
|
+
}
|
491
447
|
for (var _index = 0; _index < innerWrapperRef.current.children.length; _index++) {
|
492
448
|
var eachDiv = innerWrapperRef.current.children[_index];
|
493
|
-
|
494
449
|
if (eachDiv) {
|
495
|
-
|
450
|
+
if (!props.vertical) {
|
451
|
+
eachDiv.style[attribute] = eachChildSize + "px";
|
452
|
+
}
|
496
453
|
eachDiv.style.display = "block";
|
497
454
|
}
|
498
455
|
}
|
499
456
|
}
|
500
|
-
}, [
|
457
|
+
}, [wrapperSize, eachChildSize]);
|
501
458
|
var initResizeObserver = React.useCallback(function () {
|
502
459
|
if (wrapperRef.current) {
|
503
460
|
resizeObserver.current = new ResizeObserver(function (entries) {
|
504
461
|
if (!entries) return;
|
505
|
-
|
462
|
+
setSize();
|
506
463
|
});
|
507
464
|
resizeObserver.current.observe(wrapperRef.current);
|
508
465
|
}
|
509
466
|
}, [wrapperRef]);
|
510
467
|
var play = React.useCallback(function () {
|
511
468
|
var autoplay = props.autoplay,
|
512
|
-
|
513
|
-
|
514
|
-
|
469
|
+
infinite = props.infinite,
|
470
|
+
duration = props.duration;
|
515
471
|
if (autoplay && (infinite || index < childrenCount - 1)) {
|
516
472
|
timeout.current = setTimeout(moveNext, duration);
|
517
|
-
}
|
518
|
-
|
473
|
+
}
|
474
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
519
475
|
}, [props, childrenCount, index]);
|
520
476
|
React.useEffect(function () {
|
521
477
|
applyStyle();
|
522
|
-
}, [
|
478
|
+
}, [wrapperSize, applyStyle]);
|
523
479
|
React.useEffect(function () {
|
524
480
|
initResizeObserver();
|
525
481
|
return function () {
|
@@ -531,7 +487,7 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
531
487
|
React.useEffect(function () {
|
532
488
|
clearTimeout(timeout.current);
|
533
489
|
play();
|
534
|
-
}, [index,
|
490
|
+
}, [index, wrapperSize, props.autoplay, play]);
|
535
491
|
React.useImperativeHandle(ref, function () {
|
536
492
|
return {
|
537
493
|
goNext: function goNext() {
|
@@ -549,102 +505,80 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
549
505
|
}
|
550
506
|
};
|
551
507
|
});
|
552
|
-
|
553
508
|
var removeResizeObserver = function removeResizeObserver() {
|
554
509
|
if (resizeObserver && wrapperRef.current) {
|
555
510
|
resizeObserver.current.unobserve(wrapperRef.current);
|
556
511
|
}
|
557
512
|
};
|
558
|
-
|
559
513
|
var pauseSlides = function pauseSlides() {
|
560
514
|
if (props.pauseOnHover) {
|
561
515
|
clearTimeout(timeout.current);
|
562
516
|
}
|
563
517
|
};
|
564
|
-
|
565
518
|
var swipe = function swipe(event) {
|
566
519
|
if (props.canSwipe && dragging) {
|
567
|
-
var
|
568
|
-
|
520
|
+
var position;
|
569
521
|
if (window.TouchEvent && event.nativeEvent instanceof TouchEvent) {
|
570
|
-
|
571
|
-
} else
|
572
|
-
|
522
|
+
position = event.nativeEvent.touches[0][swipePageAttributeType];
|
523
|
+
} else {
|
524
|
+
position = event.nativeEvent[swipeAttributeType];
|
573
525
|
}
|
574
|
-
|
575
|
-
|
576
|
-
var
|
577
|
-
var distance = clientX - startingClientX;
|
578
|
-
|
526
|
+
if (position && startingSwipePosition) {
|
527
|
+
var translateValue = eachChildSize * (index + getOffset());
|
528
|
+
var distance = position - startingSwipePosition;
|
579
529
|
if (!props.infinite && index === childrenCount - slidesToScroll && distance < 0) {
|
580
530
|
// if it is the last and infinite is false and you're swiping left
|
581
531
|
// then nothing happens
|
582
532
|
return;
|
583
533
|
}
|
584
|
-
|
585
534
|
if (!props.infinite && index === 0 && distance > 0) {
|
586
535
|
// if it is the first and infinite is false and you're swiping right
|
587
536
|
// then nothing happens
|
588
537
|
return;
|
589
538
|
}
|
590
|
-
|
591
539
|
distanceSwiped = distance;
|
592
540
|
translateValue -= distanceSwiped;
|
593
|
-
innerWrapperRef.current.style.transform = "
|
541
|
+
innerWrapperRef.current.style.transform = translateType + "(-" + translateValue + "px)";
|
594
542
|
}
|
595
543
|
}
|
596
544
|
};
|
597
|
-
|
598
545
|
var moveNext = function moveNext() {
|
599
546
|
if (!props.infinite && index === childrenCount - slidesToScroll) {
|
600
547
|
return;
|
601
548
|
}
|
602
|
-
|
603
549
|
var nextIndex = calculateIndex(index + slidesToScroll);
|
604
550
|
transitionSlide(nextIndex);
|
605
551
|
};
|
606
|
-
|
607
552
|
var moveBack = function moveBack() {
|
608
553
|
if (!props.infinite && index === 0) {
|
609
554
|
return;
|
610
555
|
}
|
611
|
-
|
612
556
|
var previousIndex = index - slidesToScroll;
|
613
|
-
|
614
557
|
if (previousIndex % slidesToScroll) {
|
615
558
|
previousIndex = Math.ceil(previousIndex / slidesToScroll) * slidesToScroll;
|
616
559
|
}
|
617
|
-
|
618
560
|
transitionSlide(previousIndex);
|
619
561
|
};
|
620
|
-
|
621
562
|
var goToSlide = function goToSlide(_ref) {
|
622
563
|
var currentTarget = _ref.currentTarget;
|
623
|
-
|
624
564
|
if (!currentTarget.dataset.key) {
|
625
565
|
return;
|
626
566
|
}
|
627
|
-
|
628
567
|
var datasetKey = parseInt(currentTarget.dataset.key);
|
629
568
|
moveTo(datasetKey * slidesToScroll);
|
630
569
|
};
|
631
|
-
|
632
570
|
var moveTo = function moveTo(index) {
|
633
571
|
transitionSlide(calculateIndex(index));
|
634
572
|
};
|
635
|
-
|
636
573
|
var calculateIndex = function calculateIndex(nextIndex) {
|
637
574
|
if (nextIndex < childrenCount && nextIndex + slidesToScroll > childrenCount) {
|
638
575
|
if ((childrenCount - slidesToScroll) % slidesToScroll) {
|
639
576
|
return childrenCount - slidesToScroll;
|
640
577
|
}
|
641
|
-
|
642
578
|
return nextIndex;
|
643
579
|
}
|
644
|
-
|
645
580
|
return nextIndex;
|
646
581
|
};
|
647
|
-
|
648
582
|
var startSlides = function startSlides() {
|
649
583
|
if (dragging) {
|
650
584
|
endSwipe();
|
@@ -652,17 +586,14 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
652
586
|
timeout.current = setTimeout(moveNext, props.duration);
|
653
587
|
}
|
654
588
|
};
|
655
|
-
|
656
589
|
var moveSlides = function moveSlides(_ref2) {
|
657
590
|
var dataset = _ref2.currentTarget.dataset;
|
658
|
-
|
659
591
|
if (dataset.type === 'next') {
|
660
592
|
moveNext();
|
661
593
|
} else {
|
662
594
|
moveBack();
|
663
595
|
}
|
664
596
|
};
|
665
|
-
|
666
597
|
var renderPreceedingSlides = function renderPreceedingSlides() {
|
667
598
|
return React__default.Children.toArray(props.children).slice(-slidesToShow).map(function (each, index) {
|
668
599
|
return /*#__PURE__*/React__default.createElement("div", {
|
@@ -673,12 +604,10 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
673
604
|
}, each);
|
674
605
|
});
|
675
606
|
};
|
676
|
-
|
677
607
|
var renderTrailingSlides = function renderTrailingSlides() {
|
678
608
|
if (!props.infinite && slidesToShow === slidesToScroll) {
|
679
609
|
return;
|
680
610
|
}
|
681
|
-
|
682
611
|
return React__default.Children.toArray(props.children).slice(0, slidesToShow).map(function (each, index) {
|
683
612
|
return /*#__PURE__*/React__default.createElement("div", {
|
684
613
|
"data-index": childrenCount + index,
|
@@ -688,31 +617,33 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
688
617
|
}, each);
|
689
618
|
});
|
690
619
|
};
|
691
|
-
|
692
|
-
|
693
|
-
if (
|
694
|
-
|
620
|
+
var setSize = function setSize() {
|
621
|
+
var attribute = props.vertical ? 'clientHeight' : 'clientWidth';
|
622
|
+
if (props.vertical) {
|
623
|
+
if (innerWrapperRef.current) {
|
624
|
+
setWrapperSize(innerWrapperRef.current.children[0][attribute]);
|
625
|
+
}
|
626
|
+
} else {
|
627
|
+
if (wrapperRef.current) {
|
628
|
+
setWrapperSize(wrapperRef.current[attribute]);
|
629
|
+
}
|
695
630
|
}
|
696
631
|
};
|
697
|
-
|
698
632
|
var startSwipe = function startSwipe(event) {
|
699
633
|
if (props.canSwipe) {
|
700
634
|
if (window.TouchEvent && event.nativeEvent instanceof TouchEvent) {
|
701
|
-
|
702
|
-
} else
|
703
|
-
|
635
|
+
startingSwipePosition = event.nativeEvent.touches[0][swipePageAttributeType];
|
636
|
+
} else {
|
637
|
+
startingSwipePosition = event.nativeEvent[swipeAttributeType];
|
704
638
|
}
|
705
|
-
|
706
639
|
clearTimeout(timeout.current);
|
707
640
|
dragging = true;
|
708
641
|
}
|
709
642
|
};
|
710
|
-
|
711
643
|
var endSwipe = function endSwipe() {
|
712
644
|
if (props.canSwipe) {
|
713
645
|
dragging = false;
|
714
|
-
|
715
|
-
if (Math.abs(distanceSwiped) / wrapperWidth > 0.2) {
|
646
|
+
if (Math.abs(distanceSwiped) / wrapperSize > 0.2) {
|
716
647
|
if (distanceSwiped < 0) {
|
717
648
|
moveNext();
|
718
649
|
} else {
|
@@ -725,45 +656,39 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
725
656
|
}
|
726
657
|
}
|
727
658
|
};
|
728
|
-
|
729
659
|
var animate = function animate() {
|
730
660
|
requestAnimationFrame(animate);
|
731
661
|
tweenGroup.current.update();
|
732
662
|
};
|
733
|
-
|
734
663
|
var transitionSlide = function transitionSlide(toIndex, animationDuration) {
|
735
664
|
var transitionDuration = animationDuration || props.transitionDuration;
|
736
665
|
var currentIndex = index;
|
737
666
|
var existingTweens = tweenGroup.current.getAll();
|
738
|
-
|
739
667
|
if (!wrapperRef.current) {
|
740
668
|
return;
|
741
669
|
}
|
742
|
-
|
743
|
-
var
|
744
|
-
|
670
|
+
var attribute = props.vertical ? 'clientHeight' : 'clientWidth';
|
671
|
+
var childSize = wrapperRef.current[attribute] / slidesToShow;
|
745
672
|
if (!existingTweens.length) {
|
746
673
|
clearTimeout(timeout.current);
|
747
674
|
var value = {
|
748
|
-
margin: -
|
675
|
+
margin: -childSize * (currentIndex + getOffset()) + distanceSwiped
|
749
676
|
};
|
750
677
|
var tween = new tween_js.Tween(value, tweenGroup.current).to({
|
751
|
-
margin: -
|
678
|
+
margin: -childSize * (toIndex + getOffset())
|
752
679
|
}, transitionDuration).onUpdate(function (value) {
|
753
680
|
if (innerWrapperRef.current) {
|
754
|
-
innerWrapperRef.current.style.transform = "
|
681
|
+
innerWrapperRef.current.style.transform = translateType + "(" + value.margin + "px)";
|
755
682
|
}
|
756
683
|
});
|
757
684
|
tween.easing(getEasing(props.easing));
|
758
685
|
animate();
|
759
686
|
var newIndex = toIndex;
|
760
|
-
|
761
687
|
if (newIndex < 0) {
|
762
688
|
newIndex = childrenCount - slidesToScroll;
|
763
689
|
} else if (newIndex >= childrenCount) {
|
764
690
|
newIndex = 0;
|
765
691
|
}
|
766
|
-
|
767
692
|
tween.onStart(function () {
|
768
693
|
if (typeof props.onStartChange === 'function') {
|
769
694
|
props.onStartChange(index, newIndex);
|
@@ -771,31 +696,25 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
771
696
|
});
|
772
697
|
tween.onComplete(function () {
|
773
698
|
distanceSwiped = 0;
|
774
|
-
|
775
699
|
if (typeof props.onChange === 'function') {
|
776
700
|
props.onChange(index, newIndex);
|
777
701
|
}
|
778
|
-
|
779
702
|
setIndex(newIndex);
|
780
703
|
});
|
781
704
|
tween.start();
|
782
705
|
}
|
783
706
|
};
|
784
|
-
|
785
707
|
var isSlideActive = function isSlideActive(key) {
|
786
708
|
return key < index + slidesToShow && key >= index;
|
787
709
|
};
|
788
|
-
|
789
710
|
var getOffset = function getOffset() {
|
790
711
|
if (!props.infinite) {
|
791
712
|
return 0;
|
792
713
|
}
|
793
|
-
|
794
714
|
return slidesToShow;
|
795
715
|
};
|
796
|
-
|
797
716
|
var style = {
|
798
|
-
transform: "
|
717
|
+
transform: translateType + "(-" + (index + getOffset()) * eachChildSize + "px)"
|
799
718
|
};
|
800
719
|
return /*#__PURE__*/React__default.createElement("div", {
|
801
720
|
dir: "ltr",
|
@@ -816,7 +735,7 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
816
735
|
className: "react-slideshow-wrapper slide " + (props.cssClass || ''),
|
817
736
|
ref: wrapperRef
|
818
737
|
}, /*#__PURE__*/React__default.createElement("div", {
|
819
|
-
className: "images-wrap",
|
738
|
+
className: "images-wrap " + (props.vertical ? 'vertical' : 'horizontal'),
|
820
739
|
style: style,
|
821
740
|
ref: innerWrapperRef
|
822
741
|
}, props.infinite && renderPreceedingSlides(), (React__default.Children.map(props.children, function (thisArg) {
|
@@ -830,7 +749,7 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
830
749
|
"aria-roledescription": "slide",
|
831
750
|
"aria-hidden": isThisSlideActive ? 'false' : 'true'
|
832
751
|
}, each);
|
833
|
-
}), renderTrailingSlides())), props.arrows && showNextArrow(props, index, moveSlides)), props.indicators && showIndicators(props, index, goToSlide, responsiveSettings));
|
752
|
+
}), renderTrailingSlides())), props.arrows && showNextArrow(props, index, moveSlides)), !!props.indicators && showIndicators(props, index, goToSlide, responsiveSettings));
|
834
753
|
});
|
835
754
|
Slide.defaultProps = defaultProps;
|
836
755
|
|