@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.js
CHANGED
|
@@ -2,7 +2,10 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var React__default = _interopDefault(React);
|
|
5
|
+
var material = require('@mui/material');
|
|
5
6
|
var clsx = _interopDefault(require('clsx'));
|
|
7
|
+
var StopIcon = _interopDefault(require('@mui/icons-material/StopScreenShare'));
|
|
8
|
+
var NavigateNextIcon = _interopDefault(require('@mui/icons-material/NavigateNext'));
|
|
6
9
|
|
|
7
10
|
function _extends() {
|
|
8
11
|
_extends = Object.assign || function (target) {
|
|
@@ -197,80 +200,17 @@ function _switch(discriminant, cases) {
|
|
|
197
200
|
}
|
|
198
201
|
}
|
|
199
202
|
|
|
200
|
-
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"};
|
|
201
|
-
|
|
202
|
-
var _path, _path2;
|
|
203
|
-
|
|
204
|
-
function _extends$1() {
|
|
205
|
-
_extends$1 = Object.assign || function (target) {
|
|
206
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
207
|
-
var source = arguments[i];
|
|
208
|
-
|
|
209
|
-
for (var key in source) {
|
|
210
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
211
|
-
target[key] = source[key];
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return target;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
return _extends$1.apply(this, arguments);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
function SvgNavigateNextBlack24Dp(props) {
|
|
223
|
-
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
224
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
225
|
-
height: 24,
|
|
226
|
-
width: 24
|
|
227
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
228
|
-
d: "M0 0h24v24H0V0z",
|
|
229
|
-
fill: "none"
|
|
230
|
-
})), _path2 || (_path2 = /*#__PURE__*/React.createElement("path", {
|
|
231
|
-
d: "M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"
|
|
232
|
-
})));
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
var _path$1, _path2$1;
|
|
236
|
-
|
|
237
|
-
function _extends$2() {
|
|
238
|
-
_extends$2 = Object.assign || function (target) {
|
|
239
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
240
|
-
var source = arguments[i];
|
|
241
|
-
|
|
242
|
-
for (var key in source) {
|
|
243
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
244
|
-
target[key] = source[key];
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return target;
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
return _extends$2.apply(this, arguments);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function SvgNavigateNextBlack48Dp(props) {
|
|
256
|
-
return /*#__PURE__*/React.createElement("svg", _extends$2({
|
|
257
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
258
|
-
height: 48,
|
|
259
|
-
viewBox: "0 0 24 24",
|
|
260
|
-
width: 48
|
|
261
|
-
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
262
|
-
d: "M0 0h24v24H0V0z",
|
|
263
|
-
fill: "none"
|
|
264
|
-
})), _path2$1 || (_path2$1 = /*#__PURE__*/React.createElement("path", {
|
|
265
|
-
d: "M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"
|
|
266
|
-
})));
|
|
267
|
-
}
|
|
203
|
+
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"};
|
|
268
204
|
|
|
269
205
|
var SWIPE_TRANSITION_TIMEOUT = 400;
|
|
270
206
|
|
|
271
|
-
var getSwipes = function getSwipes(
|
|
207
|
+
var getSwipes = function getSwipes(prev, current, next, swipes) {
|
|
208
|
+
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) {
|
|
209
|
+
return swipes;
|
|
210
|
+
}
|
|
211
|
+
|
|
272
212
|
var result = [1, 2, 3].map(function (id) {
|
|
273
|
-
var item = id === 1 ? _extends({},
|
|
213
|
+
var item = id === 1 ? _extends({}, prev) : id === 2 ? current : _extends({}, next);
|
|
274
214
|
item.type = id === 1 ? 'prev' : id === 2 ? 'current' : 'next';
|
|
275
215
|
return item;
|
|
276
216
|
});
|
|
@@ -280,7 +220,7 @@ var getSwipes = function getSwipes(__prev, __current, __next) {
|
|
|
280
220
|
var getDefaultSwipe = function getDefaultSwipe() {
|
|
281
221
|
return {
|
|
282
222
|
id: Math.ceil(Math.random() * 1000),
|
|
283
|
-
children: null
|
|
223
|
+
children: React__default.createElement("div", null)
|
|
284
224
|
};
|
|
285
225
|
};
|
|
286
226
|
|
|
@@ -288,11 +228,17 @@ var refs = {};
|
|
|
288
228
|
var startClientX;
|
|
289
229
|
var lastLeft;
|
|
290
230
|
var animated = false;
|
|
231
|
+
var prePrev = null;
|
|
232
|
+
var postNext = null;
|
|
291
233
|
|
|
234
|
+
var _defaultCurrent;
|
|
235
|
+
|
|
236
|
+
var oldSwipes = [];
|
|
292
237
|
var Swiper = function Swiper(props) {
|
|
293
238
|
var defaultCurrent = props.defaultCurrent,
|
|
294
239
|
getNext = props.getNext,
|
|
295
240
|
getPrev = props.getPrev,
|
|
241
|
+
onSwipe = props.onSwipe,
|
|
296
242
|
className = props.className,
|
|
297
243
|
prevButtonRef = props.prevButtonRef,
|
|
298
244
|
nextButtonRef = props.nextButtonRef,
|
|
@@ -340,9 +286,14 @@ var Swiper = function Swiper(props) {
|
|
|
340
286
|
|
|
341
287
|
var _buttonNextRef = React.useRef(null);
|
|
342
288
|
|
|
289
|
+
if (typeof _defaultCurrent === 'undefined') {
|
|
290
|
+
_defaultCurrent = defaultCurrent;
|
|
291
|
+
}
|
|
292
|
+
|
|
343
293
|
var swipes = React.useMemo(function () {
|
|
344
|
-
return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe());
|
|
345
|
-
}, [next]);
|
|
294
|
+
return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe(), oldSwipes);
|
|
295
|
+
}, [next, prev, current]);
|
|
296
|
+
oldSwipes = swipes;
|
|
346
297
|
|
|
347
298
|
var getRef = function getRef(id) {
|
|
348
299
|
refs[id] = refs[id] ? refs[id] : React.createRef();
|
|
@@ -370,7 +321,6 @@ var Swiper = function Swiper(props) {
|
|
|
370
321
|
(_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);
|
|
371
322
|
(_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);
|
|
372
323
|
(_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);
|
|
373
|
-
setLeft(0);
|
|
374
324
|
setTimeout(function () {
|
|
375
325
|
var _getRef$current10, _getRef$current11, _getRef$current12;
|
|
376
326
|
|
|
@@ -380,56 +330,142 @@ var Swiper = function Swiper(props) {
|
|
|
380
330
|
}, SWIPE_TRANSITION_TIMEOUT);
|
|
381
331
|
};
|
|
382
332
|
|
|
333
|
+
var wait = function wait(miliseconds) {
|
|
334
|
+
try {
|
|
335
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
336
|
+
setTimeout(function () {
|
|
337
|
+
resolve(0);
|
|
338
|
+
}, miliseconds);
|
|
339
|
+
})).then(function () {});
|
|
340
|
+
} catch (e) {
|
|
341
|
+
return Promise.reject(e);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
var setPreValues = function setPreValues(_p, _n) {
|
|
346
|
+
if (_p) {
|
|
347
|
+
getPrev((_p === null || _p === void 0 ? void 0 : _p.id) || 0).then(function (d) {
|
|
348
|
+
prePrev = d;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (_n) {
|
|
353
|
+
getNext((_n === null || _n === void 0 ? void 0 : _n.id) || 0).then(function (d) {
|
|
354
|
+
postNext = d;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
383
359
|
var swipe = function swipe(_lastLeft) {
|
|
384
360
|
try {
|
|
385
|
-
var
|
|
361
|
+
var _temp7 = function _temp7(_result2) {
|
|
362
|
+
if (_exit2) return _result2;
|
|
386
363
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (_exit2) return _result;
|
|
391
|
-
setGoClass();
|
|
392
|
-
};
|
|
364
|
+
if (onSwipe !== undefined) {
|
|
365
|
+
onSwipe(currentId);
|
|
366
|
+
}
|
|
393
367
|
|
|
394
|
-
|
|
368
|
+
return 0;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
var _exit2 = false;
|
|
372
|
+
var startTime;
|
|
373
|
+
var currentId = 0;
|
|
395
374
|
|
|
396
|
-
|
|
375
|
+
var _temp8 = function () {
|
|
376
|
+
if (Math.abs(_lastLeft) > width / 3) {
|
|
377
|
+
return function () {
|
|
397
378
|
if (_lastLeft < 0) {
|
|
398
|
-
|
|
379
|
+
var _temp9 = function _temp9() {
|
|
380
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - startTime))).then(function () {
|
|
381
|
+
setLeft(0);
|
|
382
|
+
setPrev(current);
|
|
383
|
+
setCurrent(next);
|
|
384
|
+
currentId = next === null || next === void 0 ? void 0 : next.id;
|
|
385
|
+
setNext(postNext);
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
if (!(next !== null && next !== void 0 && next.id)) {
|
|
399
390
|
setBackClass();
|
|
391
|
+
setLeft(0);
|
|
400
392
|
_exit2 = true;
|
|
401
393
|
return 1;
|
|
402
394
|
}
|
|
403
395
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
396
|
+
setGoClass();
|
|
397
|
+
setLeft(windowWidth * -1);
|
|
398
|
+
startTime = new Date().getTime();
|
|
399
|
+
|
|
400
|
+
var _temp10 = function () {
|
|
401
|
+
var _postNext;
|
|
402
|
+
|
|
403
|
+
if ((next === null || next === void 0 ? void 0 : next.id) === ((_postNext = postNext) === null || _postNext === void 0 ? void 0 : _postNext.id)) {
|
|
404
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
405
|
+
var clear = setInterval(function () {
|
|
406
|
+
var _postNext2;
|
|
407
|
+
|
|
408
|
+
if ((next === null || next === void 0 ? void 0 : next.id) !== ((_postNext2 = postNext) === null || _postNext2 === void 0 ? void 0 : _postNext2.id)) {
|
|
409
|
+
clearInterval(clear);
|
|
410
|
+
resolve(0);
|
|
411
|
+
}
|
|
412
|
+
}, 0);
|
|
413
|
+
})).then(function () {});
|
|
414
|
+
}
|
|
415
|
+
}();
|
|
416
|
+
|
|
417
|
+
return _temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10);
|
|
409
418
|
} else {
|
|
410
|
-
|
|
419
|
+
var _temp11 = function _temp11() {
|
|
420
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - startTime))).then(function () {
|
|
421
|
+
setLeft(0);
|
|
422
|
+
setPrev(prePrev);
|
|
423
|
+
setCurrent(prev);
|
|
424
|
+
currentId = prev === null || prev === void 0 ? void 0 : prev.id;
|
|
425
|
+
setNext(current);
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
if (!(prev !== null && prev !== void 0 && prev.id)) {
|
|
411
430
|
setBackClass();
|
|
431
|
+
setLeft(0);
|
|
412
432
|
_exit2 = true;
|
|
413
433
|
return 1;
|
|
414
434
|
}
|
|
415
435
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
436
|
+
setGoClass();
|
|
437
|
+
setLeft(windowWidth);
|
|
438
|
+
startTime = new Date().getTime();
|
|
439
|
+
|
|
440
|
+
var _temp12 = function () {
|
|
441
|
+
var _prePrev;
|
|
442
|
+
|
|
443
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.id) === ((_prePrev = prePrev) === null || _prePrev === void 0 ? void 0 : _prePrev.id)) {
|
|
444
|
+
return Promise.resolve(new Promise(function (resolve) {
|
|
445
|
+
var clear = setInterval(function () {
|
|
446
|
+
var _prePrev2;
|
|
447
|
+
|
|
448
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.id) !== ((_prePrev2 = prePrev) === null || _prePrev2 === void 0 ? void 0 : _prePrev2.id)) {
|
|
449
|
+
clearInterval(clear);
|
|
450
|
+
resolve(0);
|
|
451
|
+
}
|
|
452
|
+
}, 0);
|
|
453
|
+
})).then(function () {});
|
|
454
|
+
}
|
|
455
|
+
}();
|
|
456
|
+
|
|
457
|
+
return _temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12);
|
|
421
458
|
}
|
|
422
459
|
}();
|
|
423
|
-
|
|
424
|
-
return _temp6 && _temp6.then ? _temp6.then(_temp5) : _temp5(_temp6);
|
|
425
460
|
} else {
|
|
426
461
|
setBackClass();
|
|
462
|
+
setLeft(0);
|
|
463
|
+
_exit2 = true;
|
|
464
|
+
return 1;
|
|
427
465
|
}
|
|
428
466
|
}();
|
|
429
467
|
|
|
430
|
-
return Promise.resolve(
|
|
431
|
-
return _exit2 ? _result2 : 0;
|
|
432
|
-
}) : _exit2 ? _temp4 : 0);
|
|
468
|
+
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
|
|
433
469
|
} catch (e) {
|
|
434
470
|
return Promise.reject(e);
|
|
435
471
|
}
|
|
@@ -444,7 +480,7 @@ var Swiper = function Swiper(props) {
|
|
|
444
480
|
var clientX = (_touches$ = touches[0]) === null || _touches$ === void 0 ? void 0 : _touches$.clientX;
|
|
445
481
|
startClientX = startClientX || 0;
|
|
446
482
|
|
|
447
|
-
var
|
|
483
|
+
var _temp14 = _switch(name, [[function () {
|
|
448
484
|
return 'onTouchStart';
|
|
449
485
|
}, function () {
|
|
450
486
|
startClientX = clientX;
|
|
@@ -463,19 +499,7 @@ var Swiper = function Swiper(props) {
|
|
|
463
499
|
});
|
|
464
500
|
}], []]);
|
|
465
501
|
|
|
466
|
-
return Promise.resolve(
|
|
467
|
-
} catch (e) {
|
|
468
|
-
return Promise.reject(e);
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
var wait = function wait(miliseconds) {
|
|
473
|
-
try {
|
|
474
|
-
return Promise.resolve(new Promise(function (resolve) {
|
|
475
|
-
setTimeout(function () {
|
|
476
|
-
resolve(0);
|
|
477
|
-
}, miliseconds);
|
|
478
|
-
})).then(function () {});
|
|
502
|
+
return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
|
|
479
503
|
} catch (e) {
|
|
480
504
|
return Promise.reject(e);
|
|
481
505
|
}
|
|
@@ -538,6 +562,29 @@ var Swiper = function Swiper(props) {
|
|
|
538
562
|
}
|
|
539
563
|
};
|
|
540
564
|
|
|
565
|
+
var infitationAnimationHandler = function infitationAnimationHandler(shift) {
|
|
566
|
+
try {
|
|
567
|
+
if (shift < 0) {
|
|
568
|
+
setGoClass();
|
|
569
|
+
} else {
|
|
570
|
+
setBackClass();
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
setLeft(shift);
|
|
574
|
+
return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT)).then(function () {
|
|
575
|
+
if (shift < 0) {
|
|
576
|
+
setBackClass();
|
|
577
|
+
} else {
|
|
578
|
+
setGoClass();
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
setLeft(0);
|
|
582
|
+
});
|
|
583
|
+
} catch (e) {
|
|
584
|
+
return Promise.reject(e);
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
|
|
541
588
|
React.useEffect(function () {
|
|
542
589
|
var _containerRef$current10, _containerRef$current11, _containerRef$current12, _containerRef$current13, _containerRef$current14, _containerRef$current15, _containerRef$current16, _containerRef$current17, _containerRef$current18;
|
|
543
590
|
|
|
@@ -564,14 +611,21 @@ var Swiper = function Swiper(props) {
|
|
|
564
611
|
setWindowWidth(_windowWidth);
|
|
565
612
|
}
|
|
566
613
|
|
|
567
|
-
if (!current || !prev || !next) {
|
|
568
|
-
setCurrent(defaultCurrent);
|
|
569
|
-
|
|
614
|
+
if (!current || !prev || !next || _defaultCurrent !== defaultCurrent) {
|
|
570
615
|
try {
|
|
571
|
-
return Promise.resolve(getNext(defaultCurrent.id)).then(function (
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
setPrev(
|
|
616
|
+
return Promise.resolve(getNext(defaultCurrent.id || 0)).then(function (_n) {
|
|
617
|
+
return Promise.resolve(getPrev(defaultCurrent.id || 0)).then(function (_p) {
|
|
618
|
+
setCurrent(defaultCurrent);
|
|
619
|
+
setPrev(_p);
|
|
620
|
+
setNext(_n);
|
|
621
|
+
setLeft(_left);
|
|
622
|
+
return Promise.resolve(getPrev(_p.id || 0)).then(function (_getPrev) {
|
|
623
|
+
prePrev = _getPrev;
|
|
624
|
+
return Promise.resolve(getNext(_n.id || 0)).then(function (_getNext) {
|
|
625
|
+
postNext = _getNext;
|
|
626
|
+
_defaultCurrent = defaultCurrent;
|
|
627
|
+
});
|
|
628
|
+
});
|
|
575
629
|
});
|
|
576
630
|
});
|
|
577
631
|
} catch (e) {
|
|
@@ -582,22 +636,36 @@ var Swiper = function Swiper(props) {
|
|
|
582
636
|
if (invitationAnimation && width && !animated) {
|
|
583
637
|
animated = true;
|
|
584
638
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
639
|
+
(function () {
|
|
640
|
+
try {
|
|
641
|
+
var _temp18 = function _temp18() {
|
|
642
|
+
var _temp15 = function () {
|
|
643
|
+
if (next !== null && next !== void 0 && next.id) {
|
|
644
|
+
return Promise.resolve(infitationAnimationHandler(-100)).then(function () {});
|
|
645
|
+
}
|
|
646
|
+
}();
|
|
647
|
+
|
|
648
|
+
if (_temp15 && _temp15.then) return _temp15.then(function () {});
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
var _temp19 = function () {
|
|
652
|
+
if (prev !== null && prev !== void 0 && prev.id) {
|
|
653
|
+
return Promise.resolve(infitationAnimationHandler(100)).then(function () {});
|
|
654
|
+
}
|
|
655
|
+
}();
|
|
656
|
+
|
|
657
|
+
return _temp19 && _temp19.then ? _temp19.then(_temp18) : _temp18(_temp19);
|
|
658
|
+
} catch (e) {
|
|
659
|
+
Promise.reject(e);
|
|
660
|
+
}
|
|
661
|
+
})();
|
|
595
662
|
}
|
|
596
663
|
|
|
597
664
|
if (typeof isMobile === 'undefined') {
|
|
598
665
|
setIsMobile('ontouchstart' in window || typeof navigator.msMaxTouchPoints !== 'undefined');
|
|
599
666
|
}
|
|
600
667
|
|
|
668
|
+
setPreValues(prev, next);
|
|
601
669
|
prevButton === null || prevButton === void 0 ? void 0 : prevButton.addEventListener('click', clickPrevHandler);
|
|
602
670
|
nextButton === null || nextButton === void 0 ? void 0 : nextButton.addEventListener('click', clickNextHandler);
|
|
603
671
|
window.addEventListener('resize', resizeHandler);
|
|
@@ -606,18 +674,20 @@ var Swiper = function Swiper(props) {
|
|
|
606
674
|
nextButton === null || nextButton === void 0 ? void 0 : nextButton.removeEventListener('click', clickNextHandler);
|
|
607
675
|
window.removeEventListener('resize', resizeHandler);
|
|
608
676
|
};
|
|
609
|
-
}, [next]);
|
|
677
|
+
}, [next, defaultCurrent]);
|
|
610
678
|
return React__default.createElement("div", {
|
|
611
679
|
className: styles.container,
|
|
612
680
|
ref: containerRef
|
|
613
681
|
}, swipes.map(function (item) {
|
|
682
|
+
var _item$id;
|
|
683
|
+
|
|
614
684
|
return React__default.createElement("div", {
|
|
615
685
|
key: item.id
|
|
616
|
-
}, item.
|
|
686
|
+
}, React__default.createElement(React__default.Fragment, null, item.id && width && React__default.createElement("div", {
|
|
617
687
|
onTouchMove: onTouchWrapper('onTouchMove'),
|
|
618
688
|
onTouchStart: onTouchWrapper('onTouchStart'),
|
|
619
689
|
onTouchEnd: onTouchWrapper('onTouchEnd'),
|
|
620
|
-
id: item.id.toString(),
|
|
690
|
+
id: (_item$id = item.id) === null || _item$id === void 0 ? void 0 : _item$id.toString(),
|
|
621
691
|
style: item.type === 'current' ? {
|
|
622
692
|
width: width,
|
|
623
693
|
height: height,
|
|
@@ -635,20 +705,36 @@ var Swiper = function Swiper(props) {
|
|
|
635
705
|
ref: getRef(item.id)
|
|
636
706
|
}, React__default.createElement("div", {
|
|
637
707
|
className: clsx(styles.content, className)
|
|
638
|
-
}, item.children))
|
|
639
|
-
|
|
708
|
+
}, item.children)), !item.id && React__default.createElement("div", {
|
|
709
|
+
style: item.type === 'current' ? {
|
|
710
|
+
width: width,
|
|
711
|
+
height: height,
|
|
712
|
+
left: left
|
|
713
|
+
} : item.type === 'prev' ? {
|
|
714
|
+
width: width,
|
|
715
|
+
height: height,
|
|
716
|
+
left: left - windowWidth
|
|
717
|
+
} : {
|
|
718
|
+
width: width,
|
|
719
|
+
height: height,
|
|
720
|
+
left: left + windowWidth
|
|
721
|
+
},
|
|
722
|
+
className: clsx(styles.card, item.type === 'prev' ? styles.prev : item.type === 'next' ? styles.next : '')
|
|
723
|
+
}, React__default.createElement(material.IconButton, {
|
|
724
|
+
disabled: true
|
|
725
|
+
}, React__default.createElement(StopIcon, null)))));
|
|
726
|
+
}), typeof isMobile !== 'undefined' && !isMobile && !prevButtonRef && (prev === null || prev === void 0 ? void 0 : prev.id) && React__default.createElement("div", {
|
|
640
727
|
className: clsx(styles.button, styles.button_prev),
|
|
641
728
|
ref: _buttonPrevRef
|
|
642
|
-
},
|
|
729
|
+
}, React__default.createElement(material.IconButton, null, React__default.createElement(NavigateNextIcon, null))), typeof isMobile !== 'undefined' && !isMobile && !nextButtonRef && (next === null || next === void 0 ? void 0 : next.id) && React__default.createElement("div", {
|
|
643
730
|
className: clsx(styles.button, styles.button_next),
|
|
644
731
|
ref: _buttonNextRef
|
|
645
|
-
},
|
|
732
|
+
}, React__default.createElement(material.IconButton, null, React__default.createElement(NavigateNextIcon, null))));
|
|
646
733
|
};
|
|
647
|
-
|
|
648
734
|
Swiper.defaultProps = {
|
|
649
735
|
className: ''
|
|
650
736
|
};
|
|
651
737
|
|
|
652
738
|
exports.SWIPE_TRANSITION_TIMEOUT = SWIPE_TRANSITION_TIMEOUT;
|
|
653
|
-
exports.
|
|
739
|
+
exports.Swiper = Swiper;
|
|
654
740
|
//# sourceMappingURL=index.js.map
|