react-slideshow-image 4.2.0 → 4.3.0

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