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