@kolserdav/swiper 1.0.10 → 2.1.1-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 +243 -148
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +248 -153
- 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, Fragment, 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(),
|
|
@@ -330,15 +275,24 @@ var Swiper = function Swiper(props) {
|
|
|
330
275
|
isMobile = _useState9[0],
|
|
331
276
|
setIsMobile = _useState9[1];
|
|
332
277
|
|
|
278
|
+
var _useState10 = useState(true),
|
|
279
|
+
load = _useState10[0],
|
|
280
|
+
setLoad = _useState10[1];
|
|
281
|
+
|
|
333
282
|
var containerRef = useRef(null);
|
|
334
283
|
|
|
335
284
|
var _buttonPrevRef = useRef(null);
|
|
336
285
|
|
|
337
286
|
var _buttonNextRef = useRef(null);
|
|
338
287
|
|
|
288
|
+
if (typeof _defaultCurrent === 'undefined') {
|
|
289
|
+
_defaultCurrent = defaultCurrent;
|
|
290
|
+
}
|
|
291
|
+
|
|
339
292
|
var swipes = useMemo(function () {
|
|
340
|
-
return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe());
|
|
341
|
-
}, [next]);
|
|
293
|
+
return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe(), oldSwipes);
|
|
294
|
+
}, [next, prev, current]);
|
|
295
|
+
oldSwipes = swipes;
|
|
342
296
|
|
|
343
297
|
var getRef = function getRef(id) {
|
|
344
298
|
refs[id] = refs[id] ? refs[id] : createRef();
|
|
@@ -366,7 +320,6 @@ var Swiper = function Swiper(props) {
|
|
|
366
320
|
(_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
321
|
(_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
322
|
(_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
323
|
setTimeout(function () {
|
|
371
324
|
var _getRef$current10, _getRef$current11, _getRef$current12;
|
|
372
325
|
|
|
@@ -376,56 +329,147 @@ var Swiper = function Swiper(props) {
|
|
|
376
329
|
}, SWIPE_TRANSITION_TIMEOUT);
|
|
377
330
|
};
|
|
378
331
|
|
|
332
|
+
var wait = function wait(miliseconds) {
|
|
333
|
+
try {
|
|
334
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
335
|
+
setTimeout(function () {
|
|
336
|
+
resolve(0);
|
|
337
|
+
}, miliseconds);
|
|
338
|
+
})).then(function () {});
|
|
339
|
+
} catch (e) {
|
|
340
|
+
return Promise.reject(e);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
var setPreValues = function setPreValues(_p, _n) {
|
|
345
|
+
if (_p) {
|
|
346
|
+
getPrev((_p === null || _p === void 0 ? void 0 : _p.id) || 0).then(function (d) {
|
|
347
|
+
prePrev = d;
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (_n) {
|
|
352
|
+
getNext((_n === null || _n === void 0 ? void 0 : _n.id) || 0).then(function (d) {
|
|
353
|
+
postNext = d;
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
|
|
379
358
|
var swipe = function swipe(_lastLeft) {
|
|
380
359
|
try {
|
|
381
|
-
var
|
|
360
|
+
var _temp7 = function _temp7(_result2) {
|
|
361
|
+
if (_exit2) return _result2;
|
|
382
362
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (_exit2) return _result;
|
|
387
|
-
setGoClass();
|
|
388
|
-
};
|
|
363
|
+
if (onSwipe !== undefined) {
|
|
364
|
+
onSwipe(currentId);
|
|
365
|
+
}
|
|
389
366
|
|
|
390
|
-
|
|
367
|
+
setLoad(false);
|
|
368
|
+
return 0;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
var _exit2 = false;
|
|
372
|
+
setLoad(true);
|
|
373
|
+
var startTime;
|
|
374
|
+
var currentId = 0;
|
|
391
375
|
|
|
392
|
-
|
|
376
|
+
var _temp8 = function () {
|
|
377
|
+
if (Math.abs(_lastLeft) > width / 3) {
|
|
378
|
+
return function () {
|
|
393
379
|
if (_lastLeft < 0) {
|
|
380
|
+
var _temp9 = function _temp9() {
|
|
381
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - startTime))).then(function () {
|
|
382
|
+
setLeft(0);
|
|
383
|
+
setPrev(current);
|
|
384
|
+
setCurrent(next);
|
|
385
|
+
currentId = next === null || next === void 0 ? void 0 : next.id;
|
|
386
|
+
setNext(postNext);
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
|
|
394
390
|
if (!(next !== null && next !== void 0 && next.id)) {
|
|
395
391
|
setBackClass();
|
|
392
|
+
setLeft(0);
|
|
393
|
+
setLoad(false);
|
|
396
394
|
_exit2 = true;
|
|
397
395
|
return 1;
|
|
398
396
|
}
|
|
399
397
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
398
|
+
setGoClass();
|
|
399
|
+
setLeft(windowWidth * -1);
|
|
400
|
+
startTime = new Date().getTime();
|
|
401
|
+
|
|
402
|
+
var _temp10 = function () {
|
|
403
|
+
var _postNext;
|
|
404
|
+
|
|
405
|
+
if ((next === null || next === void 0 ? void 0 : next.id) === ((_postNext = postNext) === null || _postNext === void 0 ? void 0 : _postNext.id)) {
|
|
406
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
407
|
+
var clear = setInterval(function () {
|
|
408
|
+
var _postNext2;
|
|
409
|
+
|
|
410
|
+
if ((next === null || next === void 0 ? void 0 : next.id) !== ((_postNext2 = postNext) === null || _postNext2 === void 0 ? void 0 : _postNext2.id)) {
|
|
411
|
+
clearInterval(clear);
|
|
412
|
+
resolve(0);
|
|
413
|
+
}
|
|
414
|
+
}, 0);
|
|
415
|
+
})).then(function () {});
|
|
416
|
+
}
|
|
417
|
+
}();
|
|
418
|
+
|
|
419
|
+
return _temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10);
|
|
405
420
|
} else {
|
|
421
|
+
var _temp11 = function _temp11() {
|
|
422
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - startTime))).then(function () {
|
|
423
|
+
setLeft(0);
|
|
424
|
+
setPrev(prePrev);
|
|
425
|
+
setCurrent(prev);
|
|
426
|
+
currentId = prev === null || prev === void 0 ? void 0 : prev.id;
|
|
427
|
+
setNext(current);
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
|
|
406
431
|
if (!(prev !== null && prev !== void 0 && prev.id)) {
|
|
407
432
|
setBackClass();
|
|
433
|
+
setLeft(0);
|
|
434
|
+
setLoad(false);
|
|
408
435
|
_exit2 = true;
|
|
409
436
|
return 1;
|
|
410
437
|
}
|
|
411
438
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
439
|
+
setGoClass();
|
|
440
|
+
setLeft(windowWidth);
|
|
441
|
+
startTime = new Date().getTime();
|
|
442
|
+
|
|
443
|
+
var _temp12 = function () {
|
|
444
|
+
var _prePrev;
|
|
445
|
+
|
|
446
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.id) === ((_prePrev = prePrev) === null || _prePrev === void 0 ? void 0 : _prePrev.id)) {
|
|
447
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
448
|
+
var clear = setInterval(function () {
|
|
449
|
+
var _prePrev2;
|
|
450
|
+
|
|
451
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.id) !== ((_prePrev2 = prePrev) === null || _prePrev2 === void 0 ? void 0 : _prePrev2.id)) {
|
|
452
|
+
clearInterval(clear);
|
|
453
|
+
resolve(0);
|
|
454
|
+
}
|
|
455
|
+
}, 0);
|
|
456
|
+
})).then(function () {});
|
|
457
|
+
}
|
|
458
|
+
}();
|
|
459
|
+
|
|
460
|
+
return _temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12);
|
|
417
461
|
}
|
|
418
462
|
}();
|
|
419
|
-
|
|
420
|
-
return _temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6);
|
|
421
463
|
} else {
|
|
422
464
|
setBackClass();
|
|
465
|
+
setLeft(0);
|
|
466
|
+
setLoad(false);
|
|
467
|
+
_exit2 = true;
|
|
468
|
+
return 1;
|
|
423
469
|
}
|
|
424
470
|
}();
|
|
425
471
|
|
|
426
|
-
return Promise.resolve(
|
|
427
|
-
return _exit2 ? _result2 : 0;
|
|
428
|
-
}) : _exit2 ? _temp4 : 0);
|
|
472
|
+
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
|
|
429
473
|
} catch (e) {
|
|
430
474
|
return Promise.reject(e);
|
|
431
475
|
}
|
|
@@ -440,7 +484,7 @@ var Swiper = function Swiper(props) {
|
|
|
440
484
|
var clientX = (_touches$ = touches[0]) === null || _touches$ === void 0 ? void 0 : _touches$.clientX;
|
|
441
485
|
startClientX = startClientX || 0;
|
|
442
486
|
|
|
443
|
-
var
|
|
487
|
+
var _temp14 = _switch(name, [[function () {
|
|
444
488
|
return 'onTouchStart';
|
|
445
489
|
}, function () {
|
|
446
490
|
startClientX = clientX;
|
|
@@ -459,19 +503,7 @@ var Swiper = function Swiper(props) {
|
|
|
459
503
|
});
|
|
460
504
|
}], []]);
|
|
461
505
|
|
|
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 () {});
|
|
506
|
+
return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
|
|
475
507
|
} catch (e) {
|
|
476
508
|
return Promise.reject(e);
|
|
477
509
|
}
|
|
@@ -487,6 +519,10 @@ var Swiper = function Swiper(props) {
|
|
|
487
519
|
var isNext = origin === 'next';
|
|
488
520
|
return function () {
|
|
489
521
|
try {
|
|
522
|
+
if (load) {
|
|
523
|
+
return Promise.resolve(1);
|
|
524
|
+
}
|
|
525
|
+
|
|
490
526
|
var coeff = isNext ? -1 : 1;
|
|
491
527
|
var leftVal = width * coeff;
|
|
492
528
|
|
|
@@ -496,9 +532,10 @@ var Swiper = function Swiper(props) {
|
|
|
496
532
|
setBackClass();
|
|
497
533
|
}
|
|
498
534
|
|
|
499
|
-
setLeft(leftVal);
|
|
500
535
|
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT / 2)).then(function () {
|
|
501
|
-
return Promise.resolve(swipe(leftVal)).then(function () {
|
|
536
|
+
return Promise.resolve(swipe(leftVal)).then(function () {
|
|
537
|
+
return 0;
|
|
538
|
+
});
|
|
502
539
|
});
|
|
503
540
|
} catch (e) {
|
|
504
541
|
return Promise.reject(e);
|
|
@@ -534,6 +571,29 @@ var Swiper = function Swiper(props) {
|
|
|
534
571
|
}
|
|
535
572
|
};
|
|
536
573
|
|
|
574
|
+
var infitationAnimationHandler = function infitationAnimationHandler(shift) {
|
|
575
|
+
try {
|
|
576
|
+
if (shift < 0) {
|
|
577
|
+
setGoClass();
|
|
578
|
+
} else {
|
|
579
|
+
setBackClass();
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
setLeft(shift);
|
|
583
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT)).then(function () {
|
|
584
|
+
if (shift < 0) {
|
|
585
|
+
setBackClass();
|
|
586
|
+
} else {
|
|
587
|
+
setGoClass();
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
setLeft(0);
|
|
591
|
+
});
|
|
592
|
+
} catch (e) {
|
|
593
|
+
return Promise.reject(e);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
|
|
537
597
|
useEffect(function () {
|
|
538
598
|
var _containerRef$current10, _containerRef$current11, _containerRef$current12, _containerRef$current13, _containerRef$current14, _containerRef$current15, _containerRef$current16, _containerRef$current17, _containerRef$current18;
|
|
539
599
|
|
|
@@ -543,8 +603,6 @@ var Swiper = function Swiper(props) {
|
|
|
543
603
|
|
|
544
604
|
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
605
|
|
|
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
606
|
var _windowWidth = document.body.clientWidth;
|
|
549
607
|
|
|
550
608
|
if (_width && !width && _height && !height) {
|
|
@@ -560,14 +618,21 @@ var Swiper = function Swiper(props) {
|
|
|
560
618
|
setWindowWidth(_windowWidth);
|
|
561
619
|
}
|
|
562
620
|
|
|
563
|
-
if (!current || !prev || !next) {
|
|
564
|
-
setCurrent(defaultCurrent);
|
|
565
|
-
|
|
621
|
+
if (!current || !prev || !next || _defaultCurrent !== defaultCurrent) {
|
|
566
622
|
try {
|
|
567
|
-
return Promise.resolve(getNext(defaultCurrent.id || 0)).then(function (
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
setPrev(
|
|
623
|
+
return Promise.resolve(getNext(defaultCurrent.id || 0)).then(function (_n) {
|
|
624
|
+
return Promise.resolve(getPrev(defaultCurrent.id || 0)).then(function (_p) {
|
|
625
|
+
setCurrent(defaultCurrent);
|
|
626
|
+
setPrev(_p);
|
|
627
|
+
setNext(_n);
|
|
628
|
+
return Promise.resolve(getPrev(_p.id || 0)).then(function (_getPrev) {
|
|
629
|
+
prePrev = _getPrev;
|
|
630
|
+
return Promise.resolve(getNext(_n.id || 0)).then(function (_getNext) {
|
|
631
|
+
postNext = _getNext;
|
|
632
|
+
_defaultCurrent = defaultCurrent;
|
|
633
|
+
setLoad(false);
|
|
634
|
+
});
|
|
635
|
+
});
|
|
571
636
|
});
|
|
572
637
|
});
|
|
573
638
|
} catch (e) {
|
|
@@ -578,43 +643,50 @@ var Swiper = function Swiper(props) {
|
|
|
578
643
|
if (invitationAnimation && width && !animated) {
|
|
579
644
|
animated = true;
|
|
580
645
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
646
|
+
(function () {
|
|
647
|
+
try {
|
|
648
|
+
var _temp18 = function _temp18() {
|
|
649
|
+
var _temp15 = function () {
|
|
650
|
+
if (next !== null && next !== void 0 && next.id) {
|
|
651
|
+
return Promise.resolve(infitationAnimationHandler(-100)).then(function () {});
|
|
652
|
+
}
|
|
653
|
+
}();
|
|
654
|
+
|
|
655
|
+
if (_temp15 && _temp15.then) return _temp15.then(function () {});
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
var _temp19 = function () {
|
|
659
|
+
if (prev !== null && prev !== void 0 && prev.id) {
|
|
660
|
+
return Promise.resolve(infitationAnimationHandler(100)).then(function () {});
|
|
661
|
+
}
|
|
662
|
+
}();
|
|
663
|
+
|
|
664
|
+
return _temp19 && _temp19.then ? _temp19.then(_temp18) : _temp18(_temp19);
|
|
665
|
+
} catch (e) {
|
|
666
|
+
Promise.reject(e);
|
|
667
|
+
}
|
|
668
|
+
})();
|
|
591
669
|
}
|
|
592
670
|
|
|
593
671
|
if (typeof isMobile === 'undefined') {
|
|
594
672
|
setIsMobile('ontouchstart' in window || typeof navigator.msMaxTouchPoints !== 'undefined');
|
|
595
673
|
}
|
|
596
674
|
|
|
597
|
-
|
|
598
|
-
nextButton === null || nextButton === void 0 ? void 0 : nextButton.addEventListener('click', clickNextHandler);
|
|
675
|
+
setPreValues(prev, next);
|
|
599
676
|
window.addEventListener('resize', resizeHandler);
|
|
600
677
|
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
678
|
window.removeEventListener('resize', resizeHandler);
|
|
604
679
|
};
|
|
605
|
-
}, [next,
|
|
606
|
-
return
|
|
680
|
+
}, [next, defaultCurrent]);
|
|
681
|
+
return React.createElement("div", {
|
|
607
682
|
className: styles.container,
|
|
608
683
|
ref: containerRef
|
|
609
684
|
}, swipes.map(function (item) {
|
|
610
685
|
var _item$id;
|
|
611
686
|
|
|
612
|
-
return
|
|
613
|
-
key: item.id
|
|
614
|
-
|
|
615
|
-
display: 'none'
|
|
616
|
-
} : {}
|
|
617
|
-
}, item.id && width && React__default.createElement("div", {
|
|
687
|
+
return React.createElement("div", {
|
|
688
|
+
key: item.id
|
|
689
|
+
}, React.createElement(Fragment, null, item.id && width && React.createElement("div", {
|
|
618
690
|
onTouchMove: onTouchWrapper('onTouchMove'),
|
|
619
691
|
onTouchStart: onTouchWrapper('onTouchStart'),
|
|
620
692
|
onTouchEnd: onTouchWrapper('onTouchEnd'),
|
|
@@ -634,16 +706,39 @@ var Swiper = function Swiper(props) {
|
|
|
634
706
|
},
|
|
635
707
|
className: clsx(styles.card, item.type === 'prev' ? styles.prev : item.type === 'next' ? styles.next : ''),
|
|
636
708
|
ref: getRef(item.id)
|
|
637
|
-
},
|
|
709
|
+
}, React.createElement("div", {
|
|
638
710
|
className: clsx(styles.content, className)
|
|
639
|
-
}, item.children))
|
|
640
|
-
|
|
711
|
+
}, item.children)), !item.id && React.createElement("div", {
|
|
712
|
+
style: item.type === 'current' ? {
|
|
713
|
+
width: width,
|
|
714
|
+
height: height,
|
|
715
|
+
left: left
|
|
716
|
+
} : item.type === 'prev' ? {
|
|
717
|
+
width: width,
|
|
718
|
+
height: height,
|
|
719
|
+
left: left - windowWidth
|
|
720
|
+
} : {
|
|
721
|
+
width: width,
|
|
722
|
+
height: height,
|
|
723
|
+
left: left + windowWidth
|
|
724
|
+
},
|
|
725
|
+
className: clsx(styles.card, item.type === 'prev' ? styles.prev : item.type === 'next' ? styles.next : '')
|
|
726
|
+
}, React.createElement(IconButton, {
|
|
727
|
+
disabled: true
|
|
728
|
+
}, React.createElement(StopIcon, null)))));
|
|
729
|
+
}), typeof isMobile !== 'undefined' && !isMobile && (prev === null || prev === void 0 ? void 0 : prev.id) && React.createElement("div", {
|
|
641
730
|
className: clsx(styles.button, styles.button_prev),
|
|
642
731
|
ref: _buttonPrevRef
|
|
643
|
-
},
|
|
732
|
+
}, React.createElement(IconButton, {
|
|
733
|
+
disabled: load,
|
|
734
|
+
onClick: clickPrevHandler
|
|
735
|
+
}, React.createElement(NavigateNextIcon, null))), typeof isMobile !== 'undefined' && !isMobile && (next === null || next === void 0 ? void 0 : next.id) && React.createElement("div", {
|
|
644
736
|
className: clsx(styles.button, styles.button_next),
|
|
645
737
|
ref: _buttonNextRef
|
|
646
|
-
},
|
|
738
|
+
}, React.createElement(IconButton, {
|
|
739
|
+
disabled: load,
|
|
740
|
+
onClick: clickNextHandler
|
|
741
|
+
}, React.createElement(NavigateNextIcon, null))));
|
|
647
742
|
};
|
|
648
743
|
Swiper.defaultProps = {
|
|
649
744
|
className: ''
|