@kolserdav/swiper 1.0.9 → 2.1.0-beta
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/README.md +58 -39
- package/dist/index.css +13 -0
- package/dist/index.d.ts +6 -10
- package/dist/index.js +225 -147
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +230 -152
- package/dist/index.modern.js.map +1 -1
- package/package.json +6 -2
package/dist/index.modern.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useState, useRef, useMemo, useEffect, createRef } from 'react';
|
|
2
|
+
import { IconButton } from '@mui/material';
|
|
2
3
|
import clsx from 'clsx';
|
|
4
|
+
import StopIcon from '@mui/icons-material/StopScreenShare';
|
|
5
|
+
import NavigateNextIcon from '@mui/icons-material/NavigateNext';
|
|
3
6
|
|
|
4
7
|
function _extends() {
|
|
5
8
|
_extends = Object.assign || function (target) {
|
|
@@ -194,80 +197,17 @@ function _switch(discriminant, cases) {
|
|
|
194
197
|
}
|
|
195
198
|
}
|
|
196
199
|
|
|
197
|
-
var styles = {"container":"_p6aGD","paper":"_3_Zua","card":"_7l_j0","prev":"_2S9j_","next":"_2T1oW","back":"_uQNyq","go":"_8240d","content":"_1EOHv","button":"_7_rsx","button_next":"_2kk22","button_prev":"_B1K5l"};
|
|
198
|
-
|
|
199
|
-
var _path, _path2;
|
|
200
|
-
|
|
201
|
-
function _extends$1() {
|
|
202
|
-
_extends$1 = Object.assign || function (target) {
|
|
203
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
204
|
-
var source = arguments[i];
|
|
205
|
-
|
|
206
|
-
for (var key in source) {
|
|
207
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
208
|
-
target[key] = source[key];
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return target;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
return _extends$1.apply(this, arguments);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function SvgNavigateNextBlack24Dp(props) {
|
|
220
|
-
return /*#__PURE__*/createElement("svg", _extends$1({
|
|
221
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
222
|
-
height: 24,
|
|
223
|
-
width: 24
|
|
224
|
-
}, props), _path || (_path = /*#__PURE__*/createElement("path", {
|
|
225
|
-
d: "M0 0h24v24H0V0z",
|
|
226
|
-
fill: "none"
|
|
227
|
-
})), _path2 || (_path2 = /*#__PURE__*/createElement("path", {
|
|
228
|
-
d: "M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"
|
|
229
|
-
})));
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
var _path$1, _path2$1;
|
|
233
|
-
|
|
234
|
-
function _extends$2() {
|
|
235
|
-
_extends$2 = Object.assign || function (target) {
|
|
236
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
237
|
-
var source = arguments[i];
|
|
238
|
-
|
|
239
|
-
for (var key in source) {
|
|
240
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
241
|
-
target[key] = source[key];
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return target;
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
return _extends$2.apply(this, arguments);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function SvgNavigateNextBlack48Dp(props) {
|
|
253
|
-
return /*#__PURE__*/createElement("svg", _extends$2({
|
|
254
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
255
|
-
height: 48,
|
|
256
|
-
viewBox: "0 0 24 24",
|
|
257
|
-
width: 48
|
|
258
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/createElement("path", {
|
|
259
|
-
d: "M0 0h24v24H0V0z",
|
|
260
|
-
fill: "none"
|
|
261
|
-
})), _path2$1 || (_path2$1 = /*#__PURE__*/createElement("path", {
|
|
262
|
-
d: "M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"
|
|
263
|
-
})));
|
|
264
|
-
}
|
|
200
|
+
var styles = {"container":"_p6aGD","paper":"_3_Zua","pipe":"_2tyje","card":"_7l_j0","prev":"_2S9j_","next":"_2T1oW","back":"_uQNyq","go":"_8240d","card__stop":"_1mqCn","content":"_1EOHv","button":"_7_rsx","button_next":"_2kk22","button_prev":"_B1K5l"};
|
|
265
201
|
|
|
266
202
|
var SWIPE_TRANSITION_TIMEOUT = 400;
|
|
267
203
|
|
|
268
|
-
var getSwipes = function getSwipes(
|
|
204
|
+
var getSwipes = function getSwipes(prev, current, next, swipes) {
|
|
205
|
+
if (((prev === null || prev === void 0 ? void 0 : prev.id) === (current === null || current === void 0 ? void 0 : current.id) || (current === null || current === void 0 ? void 0 : current.id) === (next === null || next === void 0 ? void 0 : next.id) || (next === null || next === void 0 ? void 0 : next.id) === (prev === null || prev === void 0 ? void 0 : prev.id)) && swipes.length) {
|
|
206
|
+
return swipes;
|
|
207
|
+
}
|
|
208
|
+
|
|
269
209
|
var result = [1, 2, 3].map(function (id) {
|
|
270
|
-
var item = id === 1 ? _extends({},
|
|
210
|
+
var item = id === 1 ? _extends({}, prev) : id === 2 ? current : _extends({}, next);
|
|
271
211
|
item.type = id === 1 ? 'prev' : id === 2 ? 'current' : 'next';
|
|
272
212
|
return item;
|
|
273
213
|
});
|
|
@@ -277,7 +217,7 @@ var getSwipes = function getSwipes(__prev, __current, __next) {
|
|
|
277
217
|
var getDefaultSwipe = function getDefaultSwipe() {
|
|
278
218
|
return {
|
|
279
219
|
id: Math.ceil(Math.random() * 1000),
|
|
280
|
-
children:
|
|
220
|
+
children: React.createElement("div", null)
|
|
281
221
|
};
|
|
282
222
|
};
|
|
283
223
|
|
|
@@ -285,13 +225,18 @@ var refs = {};
|
|
|
285
225
|
var startClientX;
|
|
286
226
|
var lastLeft;
|
|
287
227
|
var animated = false;
|
|
228
|
+
var prePrev = null;
|
|
229
|
+
var postNext = null;
|
|
230
|
+
|
|
231
|
+
var _defaultCurrent;
|
|
232
|
+
|
|
233
|
+
var oldSwipes = [];
|
|
288
234
|
var Swiper = function Swiper(props) {
|
|
289
235
|
var defaultCurrent = props.defaultCurrent,
|
|
290
236
|
getNext = props.getNext,
|
|
291
237
|
getPrev = props.getPrev,
|
|
238
|
+
onSwipe = props.onSwipe,
|
|
292
239
|
className = props.className,
|
|
293
|
-
prevButtonRef = props.prevButtonRef,
|
|
294
|
-
nextButtonRef = props.nextButtonRef,
|
|
295
240
|
invitationAnimation = props.invitationAnimation;
|
|
296
241
|
|
|
297
242
|
var _useState = useState(),
|
|
@@ -336,9 +281,14 @@ var Swiper = function Swiper(props) {
|
|
|
336
281
|
|
|
337
282
|
var _buttonNextRef = useRef(null);
|
|
338
283
|
|
|
284
|
+
if (typeof _defaultCurrent === 'undefined') {
|
|
285
|
+
_defaultCurrent = defaultCurrent;
|
|
286
|
+
}
|
|
287
|
+
|
|
339
288
|
var swipes = useMemo(function () {
|
|
340
|
-
return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe());
|
|
341
|
-
}, [next]);
|
|
289
|
+
return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe(), oldSwipes);
|
|
290
|
+
}, [next, prev, current]);
|
|
291
|
+
oldSwipes = swipes;
|
|
342
292
|
|
|
343
293
|
var getRef = function getRef(id) {
|
|
344
294
|
refs[id] = refs[id] ? refs[id] : createRef();
|
|
@@ -366,7 +316,6 @@ var Swiper = function Swiper(props) {
|
|
|
366
316
|
(_getRef$current7 = getRef((next === null || next === void 0 ? void 0 : next.id) || 0).current) === null || _getRef$current7 === void 0 ? void 0 : _getRef$current7.classList.add(styles.back);
|
|
367
317
|
(_getRef$current8 = getRef((prev === null || prev === void 0 ? void 0 : prev.id) || 0).current) === null || _getRef$current8 === void 0 ? void 0 : _getRef$current8.classList.add(styles.back);
|
|
368
318
|
(_getRef$current9 = getRef((current === null || current === void 0 ? void 0 : current.id) || 0).current) === null || _getRef$current9 === void 0 ? void 0 : _getRef$current9.classList.add(styles.back);
|
|
369
|
-
setLeft(0);
|
|
370
319
|
setTimeout(function () {
|
|
371
320
|
var _getRef$current10, _getRef$current11, _getRef$current12;
|
|
372
321
|
|
|
@@ -376,56 +325,142 @@ var Swiper = function Swiper(props) {
|
|
|
376
325
|
}, SWIPE_TRANSITION_TIMEOUT);
|
|
377
326
|
};
|
|
378
327
|
|
|
328
|
+
var wait = function wait(miliseconds) {
|
|
329
|
+
try {
|
|
330
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
331
|
+
setTimeout(function () {
|
|
332
|
+
resolve(0);
|
|
333
|
+
}, miliseconds);
|
|
334
|
+
})).then(function () {});
|
|
335
|
+
} catch (e) {
|
|
336
|
+
return Promise.reject(e);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
var setPreValues = function setPreValues(_p, _n) {
|
|
341
|
+
if (_p) {
|
|
342
|
+
getPrev((_p === null || _p === void 0 ? void 0 : _p.id) || 0).then(function (d) {
|
|
343
|
+
prePrev = d;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (_n) {
|
|
348
|
+
getNext((_n === null || _n === void 0 ? void 0 : _n.id) || 0).then(function (d) {
|
|
349
|
+
postNext = d;
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
379
354
|
var swipe = function swipe(_lastLeft) {
|
|
380
355
|
try {
|
|
381
|
-
var
|
|
356
|
+
var _temp7 = function _temp7(_result2) {
|
|
357
|
+
if (_exit2) return _result2;
|
|
382
358
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (_exit2) return _result;
|
|
387
|
-
setGoClass();
|
|
388
|
-
};
|
|
359
|
+
if (onSwipe !== undefined) {
|
|
360
|
+
onSwipe(currentId);
|
|
361
|
+
}
|
|
389
362
|
|
|
390
|
-
|
|
363
|
+
return 0;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
var _exit2 = false;
|
|
367
|
+
var startTime;
|
|
368
|
+
var currentId = 0;
|
|
391
369
|
|
|
392
|
-
|
|
370
|
+
var _temp8 = function () {
|
|
371
|
+
if (Math.abs(_lastLeft) > width / 3) {
|
|
372
|
+
return function () {
|
|
393
373
|
if (_lastLeft < 0) {
|
|
374
|
+
var _temp9 = function _temp9() {
|
|
375
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - startTime))).then(function () {
|
|
376
|
+
setLeft(0);
|
|
377
|
+
setPrev(current);
|
|
378
|
+
setCurrent(next);
|
|
379
|
+
currentId = next === null || next === void 0 ? void 0 : next.id;
|
|
380
|
+
setNext(postNext);
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
|
|
394
384
|
if (!(next !== null && next !== void 0 && next.id)) {
|
|
395
385
|
setBackClass();
|
|
386
|
+
setLeft(0);
|
|
396
387
|
_exit2 = true;
|
|
397
388
|
return 1;
|
|
398
389
|
}
|
|
399
390
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
391
|
+
setGoClass();
|
|
392
|
+
setLeft(windowWidth * -1);
|
|
393
|
+
startTime = new Date().getTime();
|
|
394
|
+
|
|
395
|
+
var _temp10 = function () {
|
|
396
|
+
var _postNext;
|
|
397
|
+
|
|
398
|
+
if ((next === null || next === void 0 ? void 0 : next.id) === ((_postNext = postNext) === null || _postNext === void 0 ? void 0 : _postNext.id)) {
|
|
399
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
400
|
+
var clear = setInterval(function () {
|
|
401
|
+
var _postNext2;
|
|
402
|
+
|
|
403
|
+
if ((next === null || next === void 0 ? void 0 : next.id) !== ((_postNext2 = postNext) === null || _postNext2 === void 0 ? void 0 : _postNext2.id)) {
|
|
404
|
+
clearInterval(clear);
|
|
405
|
+
resolve(0);
|
|
406
|
+
}
|
|
407
|
+
}, 0);
|
|
408
|
+
})).then(function () {});
|
|
409
|
+
}
|
|
410
|
+
}();
|
|
411
|
+
|
|
412
|
+
return _temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10);
|
|
405
413
|
} else {
|
|
414
|
+
var _temp11 = function _temp11() {
|
|
415
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - startTime))).then(function () {
|
|
416
|
+
setLeft(0);
|
|
417
|
+
setPrev(prePrev);
|
|
418
|
+
setCurrent(prev);
|
|
419
|
+
currentId = prev === null || prev === void 0 ? void 0 : prev.id;
|
|
420
|
+
setNext(current);
|
|
421
|
+
});
|
|
422
|
+
};
|
|
423
|
+
|
|
406
424
|
if (!(prev !== null && prev !== void 0 && prev.id)) {
|
|
407
425
|
setBackClass();
|
|
426
|
+
setLeft(0);
|
|
408
427
|
_exit2 = true;
|
|
409
428
|
return 1;
|
|
410
429
|
}
|
|
411
430
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
431
|
+
setGoClass();
|
|
432
|
+
setLeft(windowWidth);
|
|
433
|
+
startTime = new Date().getTime();
|
|
434
|
+
|
|
435
|
+
var _temp12 = function () {
|
|
436
|
+
var _prePrev;
|
|
437
|
+
|
|
438
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.id) === ((_prePrev = prePrev) === null || _prePrev === void 0 ? void 0 : _prePrev.id)) {
|
|
439
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
440
|
+
var clear = setInterval(function () {
|
|
441
|
+
var _prePrev2;
|
|
442
|
+
|
|
443
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.id) !== ((_prePrev2 = prePrev) === null || _prePrev2 === void 0 ? void 0 : _prePrev2.id)) {
|
|
444
|
+
clearInterval(clear);
|
|
445
|
+
resolve(0);
|
|
446
|
+
}
|
|
447
|
+
}, 0);
|
|
448
|
+
})).then(function () {});
|
|
449
|
+
}
|
|
450
|
+
}();
|
|
451
|
+
|
|
452
|
+
return _temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12);
|
|
417
453
|
}
|
|
418
454
|
}();
|
|
419
|
-
|
|
420
|
-
return _temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6);
|
|
421
455
|
} else {
|
|
422
456
|
setBackClass();
|
|
457
|
+
setLeft(0);
|
|
458
|
+
_exit2 = true;
|
|
459
|
+
return 1;
|
|
423
460
|
}
|
|
424
461
|
}();
|
|
425
462
|
|
|
426
|
-
return Promise.resolve(
|
|
427
|
-
return _exit2 ? _result2 : 0;
|
|
428
|
-
}) : _exit2 ? _temp4 : 0);
|
|
463
|
+
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
|
|
429
464
|
} catch (e) {
|
|
430
465
|
return Promise.reject(e);
|
|
431
466
|
}
|
|
@@ -440,7 +475,7 @@ var Swiper = function Swiper(props) {
|
|
|
440
475
|
var clientX = (_touches$ = touches[0]) === null || _touches$ === void 0 ? void 0 : _touches$.clientX;
|
|
441
476
|
startClientX = startClientX || 0;
|
|
442
477
|
|
|
443
|
-
var
|
|
478
|
+
var _temp14 = _switch(name, [[function () {
|
|
444
479
|
return 'onTouchStart';
|
|
445
480
|
}, function () {
|
|
446
481
|
startClientX = clientX;
|
|
@@ -459,19 +494,7 @@ var Swiper = function Swiper(props) {
|
|
|
459
494
|
});
|
|
460
495
|
}], []]);
|
|
461
496
|
|
|
462
|
-
return Promise.resolve(
|
|
463
|
-
} catch (e) {
|
|
464
|
-
return Promise.reject(e);
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
var wait = function wait(miliseconds) {
|
|
469
|
-
try {
|
|
470
|
-
return Promise.resolve(new Promise(function (resolve) {
|
|
471
|
-
setTimeout(function () {
|
|
472
|
-
resolve(0);
|
|
473
|
-
}, miliseconds);
|
|
474
|
-
})).then(function () {});
|
|
497
|
+
return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
|
|
475
498
|
} catch (e) {
|
|
476
499
|
return Promise.reject(e);
|
|
477
500
|
}
|
|
@@ -534,6 +557,29 @@ var Swiper = function Swiper(props) {
|
|
|
534
557
|
}
|
|
535
558
|
};
|
|
536
559
|
|
|
560
|
+
var infitationAnimationHandler = function infitationAnimationHandler(shift) {
|
|
561
|
+
try {
|
|
562
|
+
if (shift < 0) {
|
|
563
|
+
setGoClass();
|
|
564
|
+
} else {
|
|
565
|
+
setBackClass();
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
setLeft(shift);
|
|
569
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT)).then(function () {
|
|
570
|
+
if (shift < 0) {
|
|
571
|
+
setBackClass();
|
|
572
|
+
} else {
|
|
573
|
+
setGoClass();
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
setLeft(0);
|
|
577
|
+
});
|
|
578
|
+
} catch (e) {
|
|
579
|
+
return Promise.reject(e);
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
|
|
537
583
|
useEffect(function () {
|
|
538
584
|
var _containerRef$current10, _containerRef$current11, _containerRef$current12, _containerRef$current13, _containerRef$current14, _containerRef$current15, _containerRef$current16, _containerRef$current17, _containerRef$current18;
|
|
539
585
|
|
|
@@ -543,8 +589,6 @@ var Swiper = function Swiper(props) {
|
|
|
543
589
|
|
|
544
590
|
var __left = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current16 = containerRef.current) === null || _containerRef$current16 === void 0 ? void 0 : (_containerRef$current17 = _containerRef$current16.parentElement) === null || _containerRef$current17 === void 0 ? void 0 : (_containerRef$current18 = _containerRef$current17.getBoundingClientRect()) === null || _containerRef$current18 === void 0 ? void 0 : _containerRef$current18.left;
|
|
545
591
|
|
|
546
|
-
var prevButton = prevButtonRef ? prevButtonRef === null || prevButtonRef === void 0 ? void 0 : prevButtonRef.current : _buttonPrevRef.current;
|
|
547
|
-
var nextButton = nextButtonRef ? nextButtonRef === null || nextButtonRef === void 0 ? void 0 : nextButtonRef.current : _buttonNextRef.current;
|
|
548
592
|
var _windowWidth = document.body.clientWidth;
|
|
549
593
|
|
|
550
594
|
if (_width && !width && _height && !height) {
|
|
@@ -560,14 +604,21 @@ var Swiper = function Swiper(props) {
|
|
|
560
604
|
setWindowWidth(_windowWidth);
|
|
561
605
|
}
|
|
562
606
|
|
|
563
|
-
if (!current || !prev || !next) {
|
|
564
|
-
setCurrent(defaultCurrent);
|
|
565
|
-
|
|
607
|
+
if (!current || !prev || !next || _defaultCurrent !== defaultCurrent) {
|
|
566
608
|
try {
|
|
567
|
-
return Promise.resolve(getNext(defaultCurrent.id || 0)).then(function (
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
setPrev(
|
|
609
|
+
return Promise.resolve(getNext(defaultCurrent.id || 0)).then(function (_n) {
|
|
610
|
+
return Promise.resolve(getPrev(defaultCurrent.id || 0)).then(function (_p) {
|
|
611
|
+
setCurrent(defaultCurrent);
|
|
612
|
+
setPrev(_p);
|
|
613
|
+
setNext(_n);
|
|
614
|
+
setLeft(_left);
|
|
615
|
+
return Promise.resolve(getPrev(_p.id || 0)).then(function (_getPrev) {
|
|
616
|
+
prePrev = _getPrev;
|
|
617
|
+
return Promise.resolve(getNext(_n.id || 0)).then(function (_getNext) {
|
|
618
|
+
postNext = _getNext;
|
|
619
|
+
_defaultCurrent = defaultCurrent;
|
|
620
|
+
});
|
|
621
|
+
});
|
|
571
622
|
});
|
|
572
623
|
});
|
|
573
624
|
} catch (e) {
|
|
@@ -578,44 +629,50 @@ var Swiper = function Swiper(props) {
|
|
|
578
629
|
if (invitationAnimation && width && !animated) {
|
|
579
630
|
animated = true;
|
|
580
631
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
632
|
+
(function () {
|
|
633
|
+
try {
|
|
634
|
+
var _temp18 = function _temp18() {
|
|
635
|
+
var _temp15 = function () {
|
|
636
|
+
if (next !== null && next !== void 0 && next.id) {
|
|
637
|
+
return Promise.resolve(infitationAnimationHandler(-100)).then(function () {});
|
|
638
|
+
}
|
|
639
|
+
}();
|
|
640
|
+
|
|
641
|
+
if (_temp15 && _temp15.then) return _temp15.then(function () {});
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
var _temp19 = function () {
|
|
645
|
+
if (prev !== null && prev !== void 0 && prev.id) {
|
|
646
|
+
return Promise.resolve(infitationAnimationHandler(100)).then(function () {});
|
|
647
|
+
}
|
|
648
|
+
}();
|
|
649
|
+
|
|
650
|
+
return _temp19 && _temp19.then ? _temp19.then(_temp18) : _temp18(_temp19);
|
|
651
|
+
} catch (e) {
|
|
652
|
+
Promise.reject(e);
|
|
653
|
+
}
|
|
654
|
+
})();
|
|
591
655
|
}
|
|
592
656
|
|
|
593
657
|
if (typeof isMobile === 'undefined') {
|
|
594
658
|
setIsMobile('ontouchstart' in window || typeof navigator.msMaxTouchPoints !== 'undefined');
|
|
595
659
|
}
|
|
596
660
|
|
|
597
|
-
|
|
598
|
-
nextButton === null || nextButton === void 0 ? void 0 : nextButton.addEventListener('click', clickNextHandler);
|
|
661
|
+
setPreValues(prev, next);
|
|
599
662
|
window.addEventListener('resize', resizeHandler);
|
|
600
663
|
return function () {
|
|
601
|
-
prevButton === null || prevButton === void 0 ? void 0 : prevButton.removeEventListener('click', clickPrevHandler);
|
|
602
|
-
nextButton === null || nextButton === void 0 ? void 0 : nextButton.removeEventListener('click', clickNextHandler);
|
|
603
664
|
window.removeEventListener('resize', resizeHandler);
|
|
604
665
|
};
|
|
605
|
-
}, [next]);
|
|
606
|
-
|
|
607
|
-
return React__default.createElement("div", {
|
|
666
|
+
}, [next, defaultCurrent]);
|
|
667
|
+
return React.createElement("div", {
|
|
608
668
|
className: styles.container,
|
|
609
669
|
ref: containerRef
|
|
610
670
|
}, swipes.map(function (item) {
|
|
611
671
|
var _item$id;
|
|
612
672
|
|
|
613
|
-
return
|
|
614
|
-
key: item.id
|
|
615
|
-
|
|
616
|
-
display: 'none'
|
|
617
|
-
} : {}
|
|
618
|
-
}, item.id && width && React__default.createElement("div", {
|
|
673
|
+
return React.createElement("div", {
|
|
674
|
+
key: item.id
|
|
675
|
+
}, React.createElement(React.Fragment, null, item.id && width && React.createElement("div", {
|
|
619
676
|
onTouchMove: onTouchWrapper('onTouchMove'),
|
|
620
677
|
onTouchStart: onTouchWrapper('onTouchStart'),
|
|
621
678
|
onTouchEnd: onTouchWrapper('onTouchEnd'),
|
|
@@ -635,16 +692,37 @@ var Swiper = function Swiper(props) {
|
|
|
635
692
|
},
|
|
636
693
|
className: clsx(styles.card, item.type === 'prev' ? styles.prev : item.type === 'next' ? styles.next : ''),
|
|
637
694
|
ref: getRef(item.id)
|
|
638
|
-
},
|
|
695
|
+
}, React.createElement("div", {
|
|
639
696
|
className: clsx(styles.content, className)
|
|
640
|
-
}, item.children))
|
|
641
|
-
|
|
697
|
+
}, item.children)), !item.id && React.createElement("div", {
|
|
698
|
+
style: item.type === 'current' ? {
|
|
699
|
+
width: width,
|
|
700
|
+
height: height,
|
|
701
|
+
left: left
|
|
702
|
+
} : item.type === 'prev' ? {
|
|
703
|
+
width: width,
|
|
704
|
+
height: height,
|
|
705
|
+
left: left - windowWidth
|
|
706
|
+
} : {
|
|
707
|
+
width: width,
|
|
708
|
+
height: height,
|
|
709
|
+
left: left + windowWidth
|
|
710
|
+
},
|
|
711
|
+
className: clsx(styles.card, item.type === 'prev' ? styles.prev : item.type === 'next' ? styles.next : '')
|
|
712
|
+
}, React.createElement(IconButton, {
|
|
713
|
+
disabled: true
|
|
714
|
+
}, React.createElement(StopIcon, null)))));
|
|
715
|
+
}), typeof isMobile !== 'undefined' && !isMobile && (prev === null || prev === void 0 ? void 0 : prev.id) && React.createElement("div", {
|
|
642
716
|
className: clsx(styles.button, styles.button_prev),
|
|
643
717
|
ref: _buttonPrevRef
|
|
644
|
-
},
|
|
718
|
+
}, React.createElement(IconButton, {
|
|
719
|
+
onClick: clickPrevHandler
|
|
720
|
+
}, React.createElement(NavigateNextIcon, null))), typeof isMobile !== 'undefined' && !isMobile && (next === null || next === void 0 ? void 0 : next.id) && React.createElement("div", {
|
|
645
721
|
className: clsx(styles.button, styles.button_next),
|
|
646
722
|
ref: _buttonNextRef
|
|
647
|
-
},
|
|
723
|
+
}, React.createElement(IconButton, {
|
|
724
|
+
onClick: clickNextHandler
|
|
725
|
+
}, React.createElement(NavigateNextIcon, null))));
|
|
648
726
|
};
|
|
649
727
|
Swiper.defaultProps = {
|
|
650
728
|
className: ''
|