@kolserdav/swiper 1.0.7 → 2.0.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 +68 -39
- package/dist/index.css +13 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +226 -140
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +230 -145
- package/dist/index.modern.js.map +1 -1
- package/package.json +5 -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: null
|
|
220
|
+
children: React.createElement("div", null)
|
|
281
221
|
};
|
|
282
222
|
};
|
|
283
223
|
|
|
@@ -285,11 +225,17 @@ var refs = {};
|
|
|
285
225
|
var startClientX;
|
|
286
226
|
var lastLeft;
|
|
287
227
|
var animated = false;
|
|
228
|
+
var prePrev = null;
|
|
229
|
+
var postNext = null;
|
|
288
230
|
|
|
231
|
+
var _defaultCurrent;
|
|
232
|
+
|
|
233
|
+
var oldSwipes = [];
|
|
289
234
|
var Swiper = function Swiper(props) {
|
|
290
235
|
var defaultCurrent = props.defaultCurrent,
|
|
291
236
|
getNext = props.getNext,
|
|
292
237
|
getPrev = props.getPrev,
|
|
238
|
+
onSwipe = props.onSwipe,
|
|
293
239
|
className = props.className,
|
|
294
240
|
prevButtonRef = props.prevButtonRef,
|
|
295
241
|
nextButtonRef = props.nextButtonRef,
|
|
@@ -337,9 +283,14 @@ var Swiper = function Swiper(props) {
|
|
|
337
283
|
|
|
338
284
|
var _buttonNextRef = useRef(null);
|
|
339
285
|
|
|
286
|
+
if (typeof _defaultCurrent === 'undefined') {
|
|
287
|
+
_defaultCurrent = defaultCurrent;
|
|
288
|
+
}
|
|
289
|
+
|
|
340
290
|
var swipes = useMemo(function () {
|
|
341
|
-
return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe());
|
|
342
|
-
}, [next]);
|
|
291
|
+
return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe(), oldSwipes);
|
|
292
|
+
}, [next, prev, current]);
|
|
293
|
+
oldSwipes = swipes;
|
|
343
294
|
|
|
344
295
|
var getRef = function getRef(id) {
|
|
345
296
|
refs[id] = refs[id] ? refs[id] : createRef();
|
|
@@ -367,7 +318,6 @@ var Swiper = function Swiper(props) {
|
|
|
367
318
|
(_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);
|
|
368
319
|
(_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);
|
|
369
320
|
(_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);
|
|
370
|
-
setLeft(0);
|
|
371
321
|
setTimeout(function () {
|
|
372
322
|
var _getRef$current10, _getRef$current11, _getRef$current12;
|
|
373
323
|
|
|
@@ -377,56 +327,142 @@ var Swiper = function Swiper(props) {
|
|
|
377
327
|
}, SWIPE_TRANSITION_TIMEOUT);
|
|
378
328
|
};
|
|
379
329
|
|
|
330
|
+
var wait = function wait(miliseconds) {
|
|
331
|
+
try {
|
|
332
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
333
|
+
setTimeout(function () {
|
|
334
|
+
resolve(0);
|
|
335
|
+
}, miliseconds);
|
|
336
|
+
})).then(function () {});
|
|
337
|
+
} catch (e) {
|
|
338
|
+
return Promise.reject(e);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
var setPreValues = function setPreValues(_p, _n) {
|
|
343
|
+
if (_p) {
|
|
344
|
+
getPrev((_p === null || _p === void 0 ? void 0 : _p.id) || 0).then(function (d) {
|
|
345
|
+
prePrev = d;
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (_n) {
|
|
350
|
+
getNext((_n === null || _n === void 0 ? void 0 : _n.id) || 0).then(function (d) {
|
|
351
|
+
postNext = d;
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
380
356
|
var swipe = function swipe(_lastLeft) {
|
|
381
357
|
try {
|
|
382
|
-
var
|
|
358
|
+
var _temp7 = function _temp7(_result2) {
|
|
359
|
+
if (_exit2) return _result2;
|
|
383
360
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (_exit2) return _result;
|
|
388
|
-
setGoClass();
|
|
389
|
-
};
|
|
361
|
+
if (onSwipe !== undefined) {
|
|
362
|
+
onSwipe(currentId);
|
|
363
|
+
}
|
|
390
364
|
|
|
391
|
-
|
|
365
|
+
return 0;
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
var _exit2 = false;
|
|
369
|
+
var startTime;
|
|
370
|
+
var currentId = 0;
|
|
392
371
|
|
|
393
|
-
|
|
372
|
+
var _temp8 = function () {
|
|
373
|
+
if (Math.abs(_lastLeft) > width / 3) {
|
|
374
|
+
return function () {
|
|
394
375
|
if (_lastLeft < 0) {
|
|
395
|
-
|
|
376
|
+
var _temp9 = function _temp9() {
|
|
377
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - startTime))).then(function () {
|
|
378
|
+
setLeft(0);
|
|
379
|
+
setPrev(current);
|
|
380
|
+
setCurrent(next);
|
|
381
|
+
currentId = next === null || next === void 0 ? void 0 : next.id;
|
|
382
|
+
setNext(postNext);
|
|
383
|
+
});
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
if (!(next !== null && next !== void 0 && next.id)) {
|
|
396
387
|
setBackClass();
|
|
388
|
+
setLeft(0);
|
|
397
389
|
_exit2 = true;
|
|
398
390
|
return 1;
|
|
399
391
|
}
|
|
400
392
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
393
|
+
setGoClass();
|
|
394
|
+
setLeft(windowWidth * -1);
|
|
395
|
+
startTime = new Date().getTime();
|
|
396
|
+
|
|
397
|
+
var _temp10 = function () {
|
|
398
|
+
var _postNext;
|
|
399
|
+
|
|
400
|
+
if ((next === null || next === void 0 ? void 0 : next.id) === ((_postNext = postNext) === null || _postNext === void 0 ? void 0 : _postNext.id)) {
|
|
401
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
402
|
+
var clear = setInterval(function () {
|
|
403
|
+
var _postNext2;
|
|
404
|
+
|
|
405
|
+
if ((next === null || next === void 0 ? void 0 : next.id) !== ((_postNext2 = postNext) === null || _postNext2 === void 0 ? void 0 : _postNext2.id)) {
|
|
406
|
+
clearInterval(clear);
|
|
407
|
+
resolve(0);
|
|
408
|
+
}
|
|
409
|
+
}, 0);
|
|
410
|
+
})).then(function () {});
|
|
411
|
+
}
|
|
412
|
+
}();
|
|
413
|
+
|
|
414
|
+
return _temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10);
|
|
406
415
|
} else {
|
|
407
|
-
|
|
416
|
+
var _temp11 = function _temp11() {
|
|
417
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - startTime))).then(function () {
|
|
418
|
+
setLeft(0);
|
|
419
|
+
setPrev(prePrev);
|
|
420
|
+
setCurrent(prev);
|
|
421
|
+
currentId = prev === null || prev === void 0 ? void 0 : prev.id;
|
|
422
|
+
setNext(current);
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
if (!(prev !== null && prev !== void 0 && prev.id)) {
|
|
408
427
|
setBackClass();
|
|
428
|
+
setLeft(0);
|
|
409
429
|
_exit2 = true;
|
|
410
430
|
return 1;
|
|
411
431
|
}
|
|
412
432
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
433
|
+
setGoClass();
|
|
434
|
+
setLeft(windowWidth);
|
|
435
|
+
startTime = new Date().getTime();
|
|
436
|
+
|
|
437
|
+
var _temp12 = function () {
|
|
438
|
+
var _prePrev;
|
|
439
|
+
|
|
440
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.id) === ((_prePrev = prePrev) === null || _prePrev === void 0 ? void 0 : _prePrev.id)) {
|
|
441
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
442
|
+
var clear = setInterval(function () {
|
|
443
|
+
var _prePrev2;
|
|
444
|
+
|
|
445
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.id) !== ((_prePrev2 = prePrev) === null || _prePrev2 === void 0 ? void 0 : _prePrev2.id)) {
|
|
446
|
+
clearInterval(clear);
|
|
447
|
+
resolve(0);
|
|
448
|
+
}
|
|
449
|
+
}, 0);
|
|
450
|
+
})).then(function () {});
|
|
451
|
+
}
|
|
452
|
+
}();
|
|
453
|
+
|
|
454
|
+
return _temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12);
|
|
418
455
|
}
|
|
419
456
|
}();
|
|
420
|
-
|
|
421
|
-
return _temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6);
|
|
422
457
|
} else {
|
|
423
458
|
setBackClass();
|
|
459
|
+
setLeft(0);
|
|
460
|
+
_exit2 = true;
|
|
461
|
+
return 1;
|
|
424
462
|
}
|
|
425
463
|
}();
|
|
426
464
|
|
|
427
|
-
return Promise.resolve(
|
|
428
|
-
return _exit2 ? _result2 : 0;
|
|
429
|
-
}) : _exit2 ? _temp4 : 0);
|
|
465
|
+
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
|
|
430
466
|
} catch (e) {
|
|
431
467
|
return Promise.reject(e);
|
|
432
468
|
}
|
|
@@ -441,7 +477,7 @@ var Swiper = function Swiper(props) {
|
|
|
441
477
|
var clientX = (_touches$ = touches[0]) === null || _touches$ === void 0 ? void 0 : _touches$.clientX;
|
|
442
478
|
startClientX = startClientX || 0;
|
|
443
479
|
|
|
444
|
-
var
|
|
480
|
+
var _temp14 = _switch(name, [[function () {
|
|
445
481
|
return 'onTouchStart';
|
|
446
482
|
}, function () {
|
|
447
483
|
startClientX = clientX;
|
|
@@ -460,19 +496,7 @@ var Swiper = function Swiper(props) {
|
|
|
460
496
|
});
|
|
461
497
|
}], []]);
|
|
462
498
|
|
|
463
|
-
return Promise.resolve(
|
|
464
|
-
} catch (e) {
|
|
465
|
-
return Promise.reject(e);
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
var wait = function wait(miliseconds) {
|
|
470
|
-
try {
|
|
471
|
-
return Promise.resolve(new Promise(function (resolve) {
|
|
472
|
-
setTimeout(function () {
|
|
473
|
-
resolve(0);
|
|
474
|
-
}, miliseconds);
|
|
475
|
-
})).then(function () {});
|
|
499
|
+
return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
|
|
476
500
|
} catch (e) {
|
|
477
501
|
return Promise.reject(e);
|
|
478
502
|
}
|
|
@@ -535,6 +559,29 @@ var Swiper = function Swiper(props) {
|
|
|
535
559
|
}
|
|
536
560
|
};
|
|
537
561
|
|
|
562
|
+
var infitationAnimationHandler = function infitationAnimationHandler(shift) {
|
|
563
|
+
try {
|
|
564
|
+
if (shift < 0) {
|
|
565
|
+
setGoClass();
|
|
566
|
+
} else {
|
|
567
|
+
setBackClass();
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
setLeft(shift);
|
|
571
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT)).then(function () {
|
|
572
|
+
if (shift < 0) {
|
|
573
|
+
setBackClass();
|
|
574
|
+
} else {
|
|
575
|
+
setGoClass();
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
setLeft(0);
|
|
579
|
+
});
|
|
580
|
+
} catch (e) {
|
|
581
|
+
return Promise.reject(e);
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
538
585
|
useEffect(function () {
|
|
539
586
|
var _containerRef$current10, _containerRef$current11, _containerRef$current12, _containerRef$current13, _containerRef$current14, _containerRef$current15, _containerRef$current16, _containerRef$current17, _containerRef$current18;
|
|
540
587
|
|
|
@@ -561,14 +608,21 @@ var Swiper = function Swiper(props) {
|
|
|
561
608
|
setWindowWidth(_windowWidth);
|
|
562
609
|
}
|
|
563
610
|
|
|
564
|
-
if (!current || !prev || !next) {
|
|
565
|
-
setCurrent(defaultCurrent);
|
|
566
|
-
|
|
611
|
+
if (!current || !prev || !next || _defaultCurrent !== defaultCurrent) {
|
|
567
612
|
try {
|
|
568
|
-
return Promise.resolve(getNext(defaultCurrent.id)).then(function (
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
setPrev(
|
|
613
|
+
return Promise.resolve(getNext(defaultCurrent.id || 0)).then(function (_n) {
|
|
614
|
+
return Promise.resolve(getPrev(defaultCurrent.id || 0)).then(function (_p) {
|
|
615
|
+
setCurrent(defaultCurrent);
|
|
616
|
+
setPrev(_p);
|
|
617
|
+
setNext(_n);
|
|
618
|
+
setLeft(_left);
|
|
619
|
+
return Promise.resolve(getPrev(_p.id || 0)).then(function (_getPrev) {
|
|
620
|
+
prePrev = _getPrev;
|
|
621
|
+
return Promise.resolve(getNext(_n.id || 0)).then(function (_getNext) {
|
|
622
|
+
postNext = _getNext;
|
|
623
|
+
_defaultCurrent = defaultCurrent;
|
|
624
|
+
});
|
|
625
|
+
});
|
|
572
626
|
});
|
|
573
627
|
});
|
|
574
628
|
} catch (e) {
|
|
@@ -579,22 +633,36 @@ var Swiper = function Swiper(props) {
|
|
|
579
633
|
if (invitationAnimation && width && !animated) {
|
|
580
634
|
animated = true;
|
|
581
635
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
636
|
+
(function () {
|
|
637
|
+
try {
|
|
638
|
+
var _temp18 = function _temp18() {
|
|
639
|
+
var _temp15 = function () {
|
|
640
|
+
if (next !== null && next !== void 0 && next.id) {
|
|
641
|
+
return Promise.resolve(infitationAnimationHandler(-100)).then(function () {});
|
|
642
|
+
}
|
|
643
|
+
}();
|
|
644
|
+
|
|
645
|
+
if (_temp15 && _temp15.then) return _temp15.then(function () {});
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
var _temp19 = function () {
|
|
649
|
+
if (prev !== null && prev !== void 0 && prev.id) {
|
|
650
|
+
return Promise.resolve(infitationAnimationHandler(100)).then(function () {});
|
|
651
|
+
}
|
|
652
|
+
}();
|
|
653
|
+
|
|
654
|
+
return _temp19 && _temp19.then ? _temp19.then(_temp18) : _temp18(_temp19);
|
|
655
|
+
} catch (e) {
|
|
656
|
+
Promise.reject(e);
|
|
657
|
+
}
|
|
658
|
+
})();
|
|
592
659
|
}
|
|
593
660
|
|
|
594
661
|
if (typeof isMobile === 'undefined') {
|
|
595
662
|
setIsMobile('ontouchstart' in window || typeof navigator.msMaxTouchPoints !== 'undefined');
|
|
596
663
|
}
|
|
597
664
|
|
|
665
|
+
setPreValues(prev, next);
|
|
598
666
|
prevButton === null || prevButton === void 0 ? void 0 : prevButton.addEventListener('click', clickPrevHandler);
|
|
599
667
|
nextButton === null || nextButton === void 0 ? void 0 : nextButton.addEventListener('click', clickNextHandler);
|
|
600
668
|
window.addEventListener('resize', resizeHandler);
|
|
@@ -603,18 +671,20 @@ var Swiper = function Swiper(props) {
|
|
|
603
671
|
nextButton === null || nextButton === void 0 ? void 0 : nextButton.removeEventListener('click', clickNextHandler);
|
|
604
672
|
window.removeEventListener('resize', resizeHandler);
|
|
605
673
|
};
|
|
606
|
-
}, [next]);
|
|
607
|
-
return
|
|
674
|
+
}, [next, defaultCurrent]);
|
|
675
|
+
return React.createElement("div", {
|
|
608
676
|
className: styles.container,
|
|
609
677
|
ref: containerRef
|
|
610
678
|
}, swipes.map(function (item) {
|
|
611
|
-
|
|
679
|
+
var _item$id;
|
|
680
|
+
|
|
681
|
+
return React.createElement("div", {
|
|
612
682
|
key: item.id
|
|
613
|
-
}, item.
|
|
683
|
+
}, React.createElement(React.Fragment, null, item.id && width && React.createElement("div", {
|
|
614
684
|
onTouchMove: onTouchWrapper('onTouchMove'),
|
|
615
685
|
onTouchStart: onTouchWrapper('onTouchStart'),
|
|
616
686
|
onTouchEnd: onTouchWrapper('onTouchEnd'),
|
|
617
|
-
id: item.id.toString(),
|
|
687
|
+
id: (_item$id = item.id) === null || _item$id === void 0 ? void 0 : _item$id.toString(),
|
|
618
688
|
style: item.type === 'current' ? {
|
|
619
689
|
width: width,
|
|
620
690
|
height: height,
|
|
@@ -630,22 +700,37 @@ var Swiper = function Swiper(props) {
|
|
|
630
700
|
},
|
|
631
701
|
className: clsx(styles.card, item.type === 'prev' ? styles.prev : item.type === 'next' ? styles.next : ''),
|
|
632
702
|
ref: getRef(item.id)
|
|
633
|
-
},
|
|
703
|
+
}, React.createElement("div", {
|
|
634
704
|
className: clsx(styles.content, className)
|
|
635
|
-
}, item.children))
|
|
636
|
-
|
|
705
|
+
}, item.children)), !item.id && React.createElement("div", {
|
|
706
|
+
style: item.type === 'current' ? {
|
|
707
|
+
width: width,
|
|
708
|
+
height: height,
|
|
709
|
+
left: left
|
|
710
|
+
} : item.type === 'prev' ? {
|
|
711
|
+
width: width,
|
|
712
|
+
height: height,
|
|
713
|
+
left: left - windowWidth
|
|
714
|
+
} : {
|
|
715
|
+
width: width,
|
|
716
|
+
height: height,
|
|
717
|
+
left: left + windowWidth
|
|
718
|
+
},
|
|
719
|
+
className: clsx(styles.card, item.type === 'prev' ? styles.prev : item.type === 'next' ? styles.next : '')
|
|
720
|
+
}, React.createElement(IconButton, {
|
|
721
|
+
disabled: true
|
|
722
|
+
}, React.createElement(StopIcon, null)))));
|
|
723
|
+
}), typeof isMobile !== 'undefined' && !isMobile && !prevButtonRef && (prev === null || prev === void 0 ? void 0 : prev.id) && React.createElement("div", {
|
|
637
724
|
className: clsx(styles.button, styles.button_prev),
|
|
638
725
|
ref: _buttonPrevRef
|
|
639
|
-
},
|
|
726
|
+
}, React.createElement(IconButton, null, React.createElement(NavigateNextIcon, null))), typeof isMobile !== 'undefined' && !isMobile && !nextButtonRef && (next === null || next === void 0 ? void 0 : next.id) && React.createElement("div", {
|
|
640
727
|
className: clsx(styles.button, styles.button_next),
|
|
641
728
|
ref: _buttonNextRef
|
|
642
|
-
},
|
|
729
|
+
}, React.createElement(IconButton, null, React.createElement(NavigateNextIcon, null))));
|
|
643
730
|
};
|
|
644
|
-
|
|
645
731
|
Swiper.defaultProps = {
|
|
646
732
|
className: ''
|
|
647
733
|
};
|
|
648
734
|
|
|
649
|
-
export
|
|
650
|
-
export { SWIPE_TRANSITION_TIMEOUT };
|
|
735
|
+
export { SWIPE_TRANSITION_TIMEOUT, Swiper };
|
|
651
736
|
//# sourceMappingURL=index.modern.js.map
|