react-slideshow-image 4.3.1 → 4.4.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.
- package/dist/index.d.ts +1 -1
- package/dist/react-slideshow-image.cjs.development.js +189 -137
- 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 +189 -137
- package/dist/react-slideshow-image.esm.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +57 -16
- package/package.json +27 -21
- package/dist/props.d.ts +0 -14
package/dist/index.d.ts
CHANGED
|
@@ -10,18 +10,22 @@ var ResizeObserver = _interopDefault(require('resize-observer-polyfill'));
|
|
|
10
10
|
var tween_js = require('@tweenjs/tween.js');
|
|
11
11
|
|
|
12
12
|
function _extends() {
|
|
13
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
14
|
-
for (var
|
|
15
|
-
var
|
|
16
|
-
for (var
|
|
17
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
|
-
target[key] = source[key];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
13
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
14
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
15
|
+
var t = arguments[e];
|
|
16
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
21
17
|
}
|
|
22
|
-
return
|
|
23
|
-
};
|
|
24
|
-
|
|
18
|
+
return n;
|
|
19
|
+
}, _extends.apply(null, arguments);
|
|
20
|
+
}
|
|
21
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
22
|
+
if (null == r) return {};
|
|
23
|
+
var t = {};
|
|
24
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
25
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
26
|
+
t[n] = r[n];
|
|
27
|
+
}
|
|
28
|
+
return t;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
var getStartingIndex = function getStartingIndex(children, defaultIndex) {
|
|
@@ -156,33 +160,40 @@ var showIndicators = function showIndicators(props, currentIndex, navigate, resp
|
|
|
156
160
|
}));
|
|
157
161
|
};
|
|
158
162
|
|
|
159
|
-
var
|
|
160
|
-
duration: 5000,
|
|
161
|
-
transitionDuration: 1000,
|
|
162
|
-
defaultIndex: 0,
|
|
163
|
-
infinite: true,
|
|
164
|
-
autoplay: true,
|
|
165
|
-
indicators: false,
|
|
166
|
-
arrows: true,
|
|
167
|
-
pauseOnHover: true,
|
|
168
|
-
easing: 'linear',
|
|
169
|
-
canSwipe: true,
|
|
170
|
-
cssClass: '',
|
|
171
|
-
responsive: []
|
|
172
|
-
};
|
|
173
|
-
|
|
163
|
+
var _excluded = ["duration", "transitionDuration", "defaultIndex", "infinite", "autoplay", "indicators", "arrows", "pauseOnHover", "easing", "cssClass"];
|
|
174
164
|
var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
175
|
-
var
|
|
165
|
+
var _props$duration = props.duration,
|
|
166
|
+
duration = _props$duration === void 0 ? 5000 : _props$duration,
|
|
167
|
+
_props$transitionDura = props.transitionDuration,
|
|
168
|
+
transitionDuration = _props$transitionDura === void 0 ? 1000 : _props$transitionDura,
|
|
169
|
+
_props$defaultIndex = props.defaultIndex,
|
|
170
|
+
defaultIndex = _props$defaultIndex === void 0 ? 0 : _props$defaultIndex,
|
|
171
|
+
_props$infinite = props.infinite,
|
|
172
|
+
infinite = _props$infinite === void 0 ? true : _props$infinite,
|
|
173
|
+
_props$autoplay = props.autoplay,
|
|
174
|
+
autoplay = _props$autoplay === void 0 ? true : _props$autoplay,
|
|
175
|
+
_props$indicators = props.indicators,
|
|
176
|
+
indicators = _props$indicators === void 0 ? false : _props$indicators,
|
|
177
|
+
_props$arrows = props.arrows,
|
|
178
|
+
arrows = _props$arrows === void 0 ? true : _props$arrows,
|
|
179
|
+
_props$pauseOnHover = props.pauseOnHover,
|
|
180
|
+
pauseOnHover = _props$pauseOnHover === void 0 ? true : _props$pauseOnHover,
|
|
181
|
+
_props$easing = props.easing,
|
|
182
|
+
easing = _props$easing === void 0 ? 'linear' : _props$easing,
|
|
183
|
+
_props$cssClass = props.cssClass,
|
|
184
|
+
cssClass = _props$cssClass === void 0 ? '' : _props$cssClass,
|
|
185
|
+
others = _objectWithoutPropertiesLoose(props, _excluded);
|
|
186
|
+
var _useState = React.useState(getStartingIndex(others.children, defaultIndex)),
|
|
176
187
|
index = _useState[0],
|
|
177
188
|
setIndex = _useState[1];
|
|
178
189
|
var wrapperRef = React.useRef(null);
|
|
179
190
|
var innerWrapperRef = React.useRef(null);
|
|
180
191
|
var tweenGroup = React.useRef(new tween_js.Group());
|
|
181
|
-
var timeout = React.useRef();
|
|
182
|
-
var resizeObserver = React.useRef();
|
|
192
|
+
var timeout = React.useRef(undefined);
|
|
193
|
+
var resizeObserver = React.useRef(undefined);
|
|
183
194
|
var childrenCount = React.useMemo(function () {
|
|
184
|
-
return React__default.Children.count(
|
|
185
|
-
}, [
|
|
195
|
+
return React__default.Children.count(others.children);
|
|
196
|
+
}, [others.children]);
|
|
186
197
|
var applyStyle = React.useCallback(function () {
|
|
187
198
|
if (innerWrapperRef.current && wrapperRef.current) {
|
|
188
199
|
var wrapperWidth = wrapperRef.current.clientWidth;
|
|
@@ -208,19 +219,16 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
208
219
|
}
|
|
209
220
|
}, [wrapperRef, applyStyle]);
|
|
210
221
|
var play = React.useCallback(function () {
|
|
211
|
-
|
|
212
|
-
children = props.children,
|
|
213
|
-
duration = props.duration,
|
|
214
|
-
infinite = props.infinite;
|
|
215
|
-
if (autoplay && React__default.Children.count(children) > 1 && (infinite || index < React__default.Children.count(children) - 1)) {
|
|
222
|
+
if (autoplay && React__default.Children.count(others.children) > 1 && (infinite || index < React__default.Children.count(others.children) - 1)) {
|
|
216
223
|
timeout.current = setTimeout(moveNext, duration);
|
|
217
224
|
}
|
|
218
225
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
219
|
-
}, [
|
|
226
|
+
}, [autoplay, duration, infinite, others.children, index]);
|
|
220
227
|
React.useEffect(function () {
|
|
221
228
|
initResizeObserver();
|
|
229
|
+
var tweenGroupRef = tweenGroup.current;
|
|
222
230
|
return function () {
|
|
223
|
-
|
|
231
|
+
tweenGroupRef.removeAll();
|
|
224
232
|
clearTimeout(timeout.current);
|
|
225
233
|
removeResizeObserver();
|
|
226
234
|
};
|
|
@@ -228,7 +236,7 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
228
236
|
React.useEffect(function () {
|
|
229
237
|
clearTimeout(timeout.current);
|
|
230
238
|
play();
|
|
231
|
-
}, [index,
|
|
239
|
+
}, [index, autoplay, play]);
|
|
232
240
|
React.useEffect(function () {
|
|
233
241
|
applyStyle();
|
|
234
242
|
}, [childrenCount, applyStyle]);
|
|
@@ -255,14 +263,11 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
255
263
|
}
|
|
256
264
|
};
|
|
257
265
|
var pauseSlides = function pauseSlides() {
|
|
258
|
-
if (
|
|
266
|
+
if (pauseOnHover) {
|
|
259
267
|
clearTimeout(timeout.current);
|
|
260
268
|
}
|
|
261
269
|
};
|
|
262
270
|
var startSlides = function startSlides() {
|
|
263
|
-
var pauseOnHover = props.pauseOnHover,
|
|
264
|
-
autoplay = props.autoplay,
|
|
265
|
-
duration = props.duration;
|
|
266
271
|
if (pauseOnHover && autoplay) {
|
|
267
272
|
timeout.current = setTimeout(function () {
|
|
268
273
|
return moveNext();
|
|
@@ -270,20 +275,16 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
270
275
|
}
|
|
271
276
|
};
|
|
272
277
|
var moveNext = function moveNext() {
|
|
273
|
-
|
|
274
|
-
infinite = props.infinite;
|
|
275
|
-
if (!infinite && index === React__default.Children.count(children) - 1) {
|
|
278
|
+
if (!infinite && index === React__default.Children.count(others.children) - 1) {
|
|
276
279
|
return;
|
|
277
280
|
}
|
|
278
|
-
transitionSlide((index + 1) % React__default.Children.count(children));
|
|
281
|
+
transitionSlide((index + 1) % React__default.Children.count(others.children));
|
|
279
282
|
};
|
|
280
283
|
var moveBack = function moveBack() {
|
|
281
|
-
var children = props.children,
|
|
282
|
-
infinite = props.infinite;
|
|
283
284
|
if (!infinite && index === 0) {
|
|
284
285
|
return;
|
|
285
286
|
}
|
|
286
|
-
transitionSlide(index === 0 ? React__default.Children.count(children) - 1 : index - 1);
|
|
287
|
+
transitionSlide(index === 0 ? React__default.Children.count(others.children) - 1 : index - 1);
|
|
287
288
|
};
|
|
288
289
|
var preTransition = function preTransition(event) {
|
|
289
290
|
var currentTarget = event.currentTarget;
|
|
@@ -293,8 +294,8 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
293
294
|
moveNext();
|
|
294
295
|
}
|
|
295
296
|
};
|
|
296
|
-
var
|
|
297
|
-
requestAnimationFrame(
|
|
297
|
+
var _animate = function animate() {
|
|
298
|
+
requestAnimationFrame(_animate);
|
|
298
299
|
tweenGroup.current.update();
|
|
299
300
|
};
|
|
300
301
|
var transitionSlide = function transitionSlide(newIndex) {
|
|
@@ -309,11 +310,11 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
309
310
|
opacity: 0,
|
|
310
311
|
scale: 1
|
|
311
312
|
};
|
|
312
|
-
|
|
313
|
+
_animate();
|
|
313
314
|
var tween = new tween_js.Tween(value, tweenGroup.current).to({
|
|
314
315
|
opacity: 1,
|
|
315
|
-
scale:
|
|
316
|
-
},
|
|
316
|
+
scale: others.scale
|
|
317
|
+
}, transitionDuration).onUpdate(function (value) {
|
|
317
318
|
if (!innerWrapperRef.current) {
|
|
318
319
|
return;
|
|
319
320
|
}
|
|
@@ -321,10 +322,10 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
321
322
|
innerWrapperRef.current.children[index].style.opacity = 1 - value.opacity;
|
|
322
323
|
innerWrapperRef.current.children[index].style.transform = "scale(" + value.scale + ")";
|
|
323
324
|
});
|
|
324
|
-
tween.easing(getEasing(
|
|
325
|
+
tween.easing(getEasing(easing));
|
|
325
326
|
tween.onStart(function () {
|
|
326
|
-
if (typeof
|
|
327
|
-
|
|
327
|
+
if (typeof others.onStartChange === 'function') {
|
|
328
|
+
others.onStartChange(index, newIndex);
|
|
328
329
|
}
|
|
329
330
|
});
|
|
330
331
|
tween.onComplete(function () {
|
|
@@ -332,8 +333,8 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
332
333
|
setIndex(newIndex);
|
|
333
334
|
innerWrapperRef.current.children[index].style.transform = "scale(1)";
|
|
334
335
|
}
|
|
335
|
-
if (typeof
|
|
336
|
-
|
|
336
|
+
if (typeof others.onChange === 'function') {
|
|
337
|
+
others.onChange(index, newIndex);
|
|
337
338
|
}
|
|
338
339
|
});
|
|
339
340
|
tween.start();
|
|
@@ -357,17 +358,19 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
357
358
|
dir: "ltr",
|
|
358
359
|
"aria-roledescription": "carousel"
|
|
359
360
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
360
|
-
className: "react-slideshow-container " + (
|
|
361
|
+
className: "react-slideshow-container " + (cssClass || ''),
|
|
361
362
|
onMouseEnter: pauseSlides,
|
|
362
363
|
onMouseOver: pauseSlides,
|
|
363
364
|
onMouseLeave: startSlides
|
|
364
|
-
},
|
|
365
|
-
|
|
365
|
+
}, arrows && showPreviousArrow(_extends({}, props, {
|
|
366
|
+
infinite: infinite
|
|
367
|
+
}), index, preTransition), /*#__PURE__*/React__default.createElement("div", {
|
|
368
|
+
className: "react-slideshow-fadezoom-wrapper " + cssClass,
|
|
366
369
|
ref: wrapperRef
|
|
367
370
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
368
371
|
className: "react-slideshow-fadezoom-images-wrap",
|
|
369
372
|
ref: innerWrapperRef
|
|
370
|
-
}, (React__default.Children.map(
|
|
373
|
+
}, (React__default.Children.map(others.children, function (thisArg) {
|
|
371
374
|
return thisArg;
|
|
372
375
|
}) || []).map(function (each, key) {
|
|
373
376
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -380,27 +383,73 @@ var FadeZoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
380
383
|
"aria-roledescription": "slide",
|
|
381
384
|
"aria-hidden": key === index ? 'false' : 'true'
|
|
382
385
|
}, each);
|
|
383
|
-
}))),
|
|
386
|
+
}))), arrows && showNextArrow(_extends({}, props, {
|
|
387
|
+
infinite: infinite
|
|
388
|
+
}), index, preTransition)), indicators && showIndicators(_extends({}, props, {
|
|
389
|
+
indicators: indicators
|
|
390
|
+
}), index, navigate));
|
|
384
391
|
});
|
|
385
|
-
|
|
392
|
+
|
|
393
|
+
var defaultProps = {
|
|
394
|
+
duration: 5000,
|
|
395
|
+
transitionDuration: 1000,
|
|
396
|
+
defaultIndex: 0,
|
|
397
|
+
infinite: true,
|
|
398
|
+
autoplay: true,
|
|
399
|
+
indicators: false,
|
|
400
|
+
arrows: true,
|
|
401
|
+
pauseOnHover: true,
|
|
402
|
+
easing: 'linear',
|
|
403
|
+
canSwipe: true,
|
|
404
|
+
cssClass: ''
|
|
405
|
+
};
|
|
386
406
|
|
|
387
407
|
var Fade = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
388
|
-
return /*#__PURE__*/React__default.createElement(FadeZoom, Object.assign({}, props, {
|
|
408
|
+
return /*#__PURE__*/React__default.createElement(FadeZoom, Object.assign({}, defaultProps, props, {
|
|
389
409
|
scale: 1,
|
|
390
410
|
ref: ref
|
|
391
411
|
}));
|
|
392
412
|
});
|
|
393
|
-
Fade.defaultProps = defaultProps;
|
|
394
413
|
|
|
395
414
|
var Zoom = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
396
|
-
return /*#__PURE__*/React__default.createElement(FadeZoom, Object.assign({}, props, {
|
|
415
|
+
return /*#__PURE__*/React__default.createElement(FadeZoom, Object.assign({}, defaultProps, props, {
|
|
397
416
|
ref: ref
|
|
398
417
|
}));
|
|
399
418
|
});
|
|
400
|
-
Zoom.defaultProps = defaultProps;
|
|
401
419
|
|
|
420
|
+
var _excluded$1 = ["duration", "transitionDuration", "defaultIndex", "infinite", "autoplay", "indicators", "arrows", "pauseOnHover", "easing", "canSwipe", "cssClass", "responsive", "slidesToShow", "slidesToScroll"];
|
|
402
421
|
var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
403
|
-
var
|
|
422
|
+
var _props$duration = props.duration,
|
|
423
|
+
duration = _props$duration === void 0 ? 5000 : _props$duration,
|
|
424
|
+
_props$transitionDura = props.transitionDuration,
|
|
425
|
+
transitionDuration = _props$transitionDura === void 0 ? 1000 : _props$transitionDura,
|
|
426
|
+
_props$defaultIndex = props.defaultIndex,
|
|
427
|
+
defaultIndex = _props$defaultIndex === void 0 ? 0 : _props$defaultIndex,
|
|
428
|
+
_props$infinite = props.infinite,
|
|
429
|
+
infinite = _props$infinite === void 0 ? true : _props$infinite,
|
|
430
|
+
_props$autoplay = props.autoplay,
|
|
431
|
+
autoplay = _props$autoplay === void 0 ? true : _props$autoplay,
|
|
432
|
+
_props$indicators = props.indicators,
|
|
433
|
+
indicators = _props$indicators === void 0 ? false : _props$indicators,
|
|
434
|
+
_props$arrows = props.arrows,
|
|
435
|
+
arrows = _props$arrows === void 0 ? true : _props$arrows,
|
|
436
|
+
_props$pauseOnHover = props.pauseOnHover,
|
|
437
|
+
pauseOnHover = _props$pauseOnHover === void 0 ? true : _props$pauseOnHover,
|
|
438
|
+
_props$easing = props.easing,
|
|
439
|
+
easing = _props$easing === void 0 ? 'linear' : _props$easing,
|
|
440
|
+
_props$canSwipe = props.canSwipe,
|
|
441
|
+
canSwipe = _props$canSwipe === void 0 ? true : _props$canSwipe,
|
|
442
|
+
_props$cssClass = props.cssClass,
|
|
443
|
+
cssClass = _props$cssClass === void 0 ? '' : _props$cssClass,
|
|
444
|
+
_props$responsive = props.responsive,
|
|
445
|
+
responsive = _props$responsive === void 0 ? [] : _props$responsive,
|
|
446
|
+
_props$slidesToShow = props.slidesToShow,
|
|
447
|
+
slidesToShowDefault = _props$slidesToShow === void 0 ? 1 : _props$slidesToShow,
|
|
448
|
+
_props$slidesToScroll = props.slidesToScroll,
|
|
449
|
+
slidesToScrollDefault = _props$slidesToScroll === void 0 ? 1 : _props$slidesToScroll,
|
|
450
|
+
others = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
451
|
+
var newTransitionDuration = transitionDuration;
|
|
452
|
+
var _useState = React.useState(getStartingIndex(others.children, defaultIndex)),
|
|
404
453
|
index = _useState[0],
|
|
405
454
|
setIndex = _useState[1];
|
|
406
455
|
var _useState2 = React.useState(0),
|
|
@@ -410,53 +459,65 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
410
459
|
var innerWrapperRef = React.useRef(null);
|
|
411
460
|
var tweenGroup = React.useRef(new tween_js.Group());
|
|
412
461
|
var responsiveSettings = React.useMemo(function () {
|
|
413
|
-
return getResponsiveSettings(wrapperSize,
|
|
414
|
-
}, [wrapperSize,
|
|
462
|
+
return getResponsiveSettings(wrapperSize, responsive);
|
|
463
|
+
}, [wrapperSize, responsive]);
|
|
415
464
|
var slidesToScroll = React.useMemo(function () {
|
|
416
465
|
if (responsiveSettings) {
|
|
417
466
|
return responsiveSettings.settings.slidesToScroll;
|
|
418
467
|
}
|
|
419
|
-
return
|
|
420
|
-
}, [responsiveSettings,
|
|
468
|
+
return slidesToScrollDefault;
|
|
469
|
+
}, [responsiveSettings, slidesToScrollDefault]);
|
|
421
470
|
var slidesToShow = React.useMemo(function () {
|
|
422
471
|
if (responsiveSettings) {
|
|
423
472
|
return responsiveSettings.settings.slidesToShow;
|
|
424
473
|
}
|
|
425
|
-
return
|
|
426
|
-
}, [responsiveSettings,
|
|
474
|
+
return slidesToShowDefault;
|
|
475
|
+
}, [responsiveSettings, slidesToShowDefault]);
|
|
427
476
|
var childrenCount = React.useMemo(function () {
|
|
428
|
-
return React__default.Children.count(
|
|
429
|
-
}, [
|
|
477
|
+
return React__default.Children.count(others.children);
|
|
478
|
+
}, [others.children]);
|
|
430
479
|
var eachChildSize = React.useMemo(function () {
|
|
431
480
|
return wrapperSize / slidesToShow;
|
|
432
481
|
}, [wrapperSize, slidesToShow]);
|
|
433
|
-
var timeout = React.useRef();
|
|
434
|
-
var resizeObserver = React.useRef();
|
|
482
|
+
var timeout = React.useRef(undefined);
|
|
483
|
+
var resizeObserver = React.useRef(undefined);
|
|
435
484
|
var startingSwipePosition;
|
|
436
485
|
var dragging = false;
|
|
437
486
|
var distanceSwiped = 0;
|
|
438
|
-
var translateType =
|
|
439
|
-
var swipeAttributeType =
|
|
440
|
-
var swipePageAttributeType =
|
|
487
|
+
var translateType = others.vertical ? 'translateY' : 'translateX';
|
|
488
|
+
var swipeAttributeType = others.vertical ? 'clientY' : 'clientX';
|
|
489
|
+
var swipePageAttributeType = others.vertical ? 'pageY' : 'pageX';
|
|
441
490
|
var applyStyle = React.useCallback(function () {
|
|
442
491
|
if (innerWrapperRef.current) {
|
|
443
492
|
var fullSize = wrapperSize * innerWrapperRef.current.children.length;
|
|
444
|
-
var attribute =
|
|
493
|
+
var attribute = others.vertical ? 'height' : 'width';
|
|
445
494
|
innerWrapperRef.current.style[attribute] = fullSize + "px";
|
|
446
|
-
if (
|
|
495
|
+
if (others.vertical && wrapperRef.current) {
|
|
447
496
|
wrapperRef.current.style[attribute] = wrapperSize + "px";
|
|
448
497
|
}
|
|
449
498
|
for (var _index = 0; _index < innerWrapperRef.current.children.length; _index++) {
|
|
450
499
|
var eachDiv = innerWrapperRef.current.children[_index];
|
|
451
500
|
if (eachDiv) {
|
|
452
|
-
if (!
|
|
501
|
+
if (!others.vertical) {
|
|
453
502
|
eachDiv.style[attribute] = eachChildSize + "px";
|
|
454
503
|
}
|
|
455
504
|
eachDiv.style.display = "block";
|
|
456
505
|
}
|
|
457
506
|
}
|
|
458
507
|
}
|
|
459
|
-
}, [wrapperSize, eachChildSize]);
|
|
508
|
+
}, [wrapperSize, eachChildSize, others.vertical]);
|
|
509
|
+
var setSize = React.useCallback(function () {
|
|
510
|
+
var attribute = others.vertical ? 'clientHeight' : 'clientWidth';
|
|
511
|
+
if (others.vertical) {
|
|
512
|
+
if (innerWrapperRef.current) {
|
|
513
|
+
setWrapperSize(innerWrapperRef.current.children[0][attribute]);
|
|
514
|
+
}
|
|
515
|
+
} else {
|
|
516
|
+
if (wrapperRef.current) {
|
|
517
|
+
setWrapperSize(wrapperRef.current[attribute]);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}, [others.vertical]);
|
|
460
521
|
var initResizeObserver = React.useCallback(function () {
|
|
461
522
|
if (wrapperRef.current) {
|
|
462
523
|
resizeObserver.current = new ResizeObserver(function (entries) {
|
|
@@ -465,23 +526,21 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
465
526
|
});
|
|
466
527
|
resizeObserver.current.observe(wrapperRef.current);
|
|
467
528
|
}
|
|
468
|
-
}, [wrapperRef]);
|
|
529
|
+
}, [wrapperRef, setSize]);
|
|
469
530
|
var play = React.useCallback(function () {
|
|
470
|
-
var autoplay = props.autoplay,
|
|
471
|
-
infinite = props.infinite,
|
|
472
|
-
duration = props.duration;
|
|
473
531
|
if (autoplay && (infinite || index < childrenCount - 1)) {
|
|
474
532
|
timeout.current = setTimeout(moveNext, duration);
|
|
475
533
|
}
|
|
476
534
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
477
|
-
}, [
|
|
535
|
+
}, [autoplay, infinite, duration, childrenCount, index]);
|
|
478
536
|
React.useEffect(function () {
|
|
479
537
|
applyStyle();
|
|
480
538
|
}, [wrapperSize, applyStyle]);
|
|
481
539
|
React.useEffect(function () {
|
|
482
540
|
initResizeObserver();
|
|
541
|
+
var tweenGroupRef = tweenGroup.current;
|
|
483
542
|
return function () {
|
|
484
|
-
|
|
543
|
+
tweenGroupRef.removeAll();
|
|
485
544
|
clearTimeout(timeout.current);
|
|
486
545
|
removeResizeObserver();
|
|
487
546
|
};
|
|
@@ -489,7 +548,7 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
489
548
|
React.useEffect(function () {
|
|
490
549
|
clearTimeout(timeout.current);
|
|
491
550
|
play();
|
|
492
|
-
}, [index, wrapperSize,
|
|
551
|
+
}, [index, wrapperSize, autoplay, play]);
|
|
493
552
|
React.useImperativeHandle(ref, function () {
|
|
494
553
|
return {
|
|
495
554
|
goNext: function goNext() {
|
|
@@ -513,12 +572,12 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
513
572
|
}
|
|
514
573
|
};
|
|
515
574
|
var pauseSlides = function pauseSlides() {
|
|
516
|
-
if (
|
|
575
|
+
if (pauseOnHover) {
|
|
517
576
|
clearTimeout(timeout.current);
|
|
518
577
|
}
|
|
519
578
|
};
|
|
520
579
|
var swipe = function swipe(event) {
|
|
521
|
-
if (
|
|
580
|
+
if (canSwipe && dragging) {
|
|
522
581
|
var position;
|
|
523
582
|
if (window.TouchEvent && event.nativeEvent instanceof TouchEvent) {
|
|
524
583
|
position = event.nativeEvent.touches[0][swipePageAttributeType];
|
|
@@ -528,12 +587,12 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
528
587
|
if (position && startingSwipePosition) {
|
|
529
588
|
var translateValue = eachChildSize * (index + getOffset());
|
|
530
589
|
var distance = position - startingSwipePosition;
|
|
531
|
-
if (!
|
|
590
|
+
if (!infinite && index === childrenCount - slidesToScroll && distance < 0) {
|
|
532
591
|
// if it is the last and infinite is false and you're swiping left
|
|
533
592
|
// then nothing happens
|
|
534
593
|
return;
|
|
535
594
|
}
|
|
536
|
-
if (!
|
|
595
|
+
if (!infinite && index === 0 && distance > 0) {
|
|
537
596
|
// if it is the first and infinite is false and you're swiping right
|
|
538
597
|
// then nothing happens
|
|
539
598
|
return;
|
|
@@ -545,14 +604,14 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
545
604
|
}
|
|
546
605
|
};
|
|
547
606
|
var moveNext = function moveNext() {
|
|
548
|
-
if (!
|
|
607
|
+
if (!infinite && index === childrenCount - slidesToScroll) {
|
|
549
608
|
return;
|
|
550
609
|
}
|
|
551
610
|
var nextIndex = calculateIndex(index + slidesToScroll);
|
|
552
611
|
transitionSlide(nextIndex);
|
|
553
612
|
};
|
|
554
613
|
var moveBack = function moveBack() {
|
|
555
|
-
if (!
|
|
614
|
+
if (!infinite && index === 0) {
|
|
556
615
|
return;
|
|
557
616
|
}
|
|
558
617
|
var previousIndex = index - slidesToScroll;
|
|
@@ -584,8 +643,8 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
584
643
|
var startSlides = function startSlides() {
|
|
585
644
|
if (dragging) {
|
|
586
645
|
endSwipe();
|
|
587
|
-
} else if (
|
|
588
|
-
timeout.current = setTimeout(moveNext,
|
|
646
|
+
} else if (pauseOnHover && autoplay) {
|
|
647
|
+
timeout.current = setTimeout(moveNext, duration);
|
|
589
648
|
}
|
|
590
649
|
};
|
|
591
650
|
var moveSlides = function moveSlides(_ref2) {
|
|
@@ -597,7 +656,7 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
597
656
|
}
|
|
598
657
|
};
|
|
599
658
|
var renderPreceedingSlides = function renderPreceedingSlides() {
|
|
600
|
-
return React__default.Children.toArray(
|
|
659
|
+
return React__default.Children.toArray(others.children).slice(-slidesToShow).map(function (each, index) {
|
|
601
660
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
602
661
|
"data-index": index - slidesToShow,
|
|
603
662
|
"aria-roledescription": "slide",
|
|
@@ -607,10 +666,10 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
607
666
|
});
|
|
608
667
|
};
|
|
609
668
|
var renderTrailingSlides = function renderTrailingSlides() {
|
|
610
|
-
if (!
|
|
669
|
+
if (!infinite && slidesToShow === slidesToScroll) {
|
|
611
670
|
return;
|
|
612
671
|
}
|
|
613
|
-
return React__default.Children.toArray(
|
|
672
|
+
return React__default.Children.toArray(others.children).slice(0, slidesToShow).map(function (each, index) {
|
|
614
673
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
615
674
|
"data-index": childrenCount + index,
|
|
616
675
|
"aria-roledescription": "slide",
|
|
@@ -619,20 +678,8 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
619
678
|
}, each);
|
|
620
679
|
});
|
|
621
680
|
};
|
|
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
|
-
}
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
681
|
var startSwipe = function startSwipe(event) {
|
|
635
|
-
if (
|
|
682
|
+
if (canSwipe) {
|
|
636
683
|
if (window.TouchEvent && event.nativeEvent instanceof TouchEvent) {
|
|
637
684
|
startingSwipePosition = event.nativeEvent.touches[0][swipePageAttributeType];
|
|
638
685
|
} else {
|
|
@@ -643,7 +690,7 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
643
690
|
}
|
|
644
691
|
};
|
|
645
692
|
var endSwipe = function endSwipe() {
|
|
646
|
-
if (
|
|
693
|
+
if (canSwipe) {
|
|
647
694
|
dragging = false;
|
|
648
695
|
if (Math.abs(distanceSwiped) / wrapperSize > 0.2) {
|
|
649
696
|
if (distanceSwiped < 0) {
|
|
@@ -658,18 +705,18 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
658
705
|
}
|
|
659
706
|
}
|
|
660
707
|
};
|
|
661
|
-
var
|
|
662
|
-
requestAnimationFrame(
|
|
708
|
+
var _animate = function animate() {
|
|
709
|
+
requestAnimationFrame(_animate);
|
|
663
710
|
tweenGroup.current.update();
|
|
664
711
|
};
|
|
665
712
|
var transitionSlide = function transitionSlide(toIndex, animationDuration) {
|
|
666
|
-
var transitionDuration = animationDuration ||
|
|
713
|
+
var transitionDuration = animationDuration || newTransitionDuration;
|
|
667
714
|
var currentIndex = index;
|
|
668
715
|
var existingTweens = tweenGroup.current.getAll();
|
|
669
716
|
if (!wrapperRef.current) {
|
|
670
717
|
return;
|
|
671
718
|
}
|
|
672
|
-
var attribute =
|
|
719
|
+
var attribute = others.vertical ? 'clientHeight' : 'clientWidth';
|
|
673
720
|
var childSize = wrapperRef.current[attribute] / slidesToShow;
|
|
674
721
|
if (!existingTweens.length) {
|
|
675
722
|
clearTimeout(timeout.current);
|
|
@@ -683,8 +730,8 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
683
730
|
innerWrapperRef.current.style.transform = translateType + "(" + value.margin + "px)";
|
|
684
731
|
}
|
|
685
732
|
});
|
|
686
|
-
tween.easing(getEasing(
|
|
687
|
-
|
|
733
|
+
tween.easing(getEasing(easing));
|
|
734
|
+
_animate();
|
|
688
735
|
var newIndex = toIndex;
|
|
689
736
|
if (newIndex < 0) {
|
|
690
737
|
newIndex = childrenCount - slidesToScroll;
|
|
@@ -692,14 +739,14 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
692
739
|
newIndex = 0;
|
|
693
740
|
}
|
|
694
741
|
tween.onStart(function () {
|
|
695
|
-
if (typeof
|
|
696
|
-
|
|
742
|
+
if (typeof others.onStartChange === 'function') {
|
|
743
|
+
others.onStartChange(index, newIndex);
|
|
697
744
|
}
|
|
698
745
|
});
|
|
699
746
|
tween.onComplete(function () {
|
|
700
747
|
distanceSwiped = 0;
|
|
701
|
-
if (typeof
|
|
702
|
-
|
|
748
|
+
if (typeof others.onChange === 'function') {
|
|
749
|
+
others.onChange(index, newIndex);
|
|
703
750
|
}
|
|
704
751
|
setIndex(newIndex);
|
|
705
752
|
});
|
|
@@ -710,7 +757,7 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
710
757
|
return key < index + slidesToShow && key >= index;
|
|
711
758
|
};
|
|
712
759
|
var getOffset = function getOffset() {
|
|
713
|
-
if (!
|
|
760
|
+
if (!infinite) {
|
|
714
761
|
return 0;
|
|
715
762
|
}
|
|
716
763
|
return slidesToShow;
|
|
@@ -733,14 +780,16 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
733
780
|
onTouchEnd: endSwipe,
|
|
734
781
|
onTouchCancel: endSwipe,
|
|
735
782
|
onTouchMove: swipe
|
|
736
|
-
},
|
|
737
|
-
|
|
783
|
+
}, arrows && showPreviousArrow(_extends({}, props, {
|
|
784
|
+
infinite: infinite
|
|
785
|
+
}), index, moveSlides), /*#__PURE__*/React__default.createElement("div", {
|
|
786
|
+
className: "react-slideshow-wrapper slide " + (cssClass || ''),
|
|
738
787
|
ref: wrapperRef
|
|
739
788
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
740
|
-
className: "images-wrap " + (
|
|
789
|
+
className: "images-wrap " + (others.vertical ? 'vertical' : 'horizontal'),
|
|
741
790
|
style: style,
|
|
742
791
|
ref: innerWrapperRef
|
|
743
|
-
},
|
|
792
|
+
}, infinite && renderPreceedingSlides(), (React__default.Children.map(others.children, function (thisArg) {
|
|
744
793
|
return thisArg;
|
|
745
794
|
}) || []).map(function (each, key) {
|
|
746
795
|
var isThisSlideActive = isSlideActive(key);
|
|
@@ -751,9 +800,12 @@ var Slide = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
|
751
800
|
"aria-roledescription": "slide",
|
|
752
801
|
"aria-hidden": isThisSlideActive ? 'false' : 'true'
|
|
753
802
|
}, each);
|
|
754
|
-
}), renderTrailingSlides())),
|
|
803
|
+
}), renderTrailingSlides())), arrows && showNextArrow(_extends({}, props, {
|
|
804
|
+
infinite: infinite
|
|
805
|
+
}), index, moveSlides, responsiveSettings)), !!indicators && showIndicators(_extends({}, props, {
|
|
806
|
+
indicators: indicators
|
|
807
|
+
}), index, goToSlide, responsiveSettings));
|
|
755
808
|
});
|
|
756
|
-
Slide.defaultProps = defaultProps;
|
|
757
809
|
|
|
758
810
|
exports.Fade = Fade;
|
|
759
811
|
exports.Slide = Slide;
|