@kolserdav/swiper 4.1.5 → 4.2.1

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.js CHANGED
@@ -1,914 +1,3 @@
1
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2
-
3
- var React = require('react');
4
- var React__default = _interopDefault(React);
5
- var clsx = _interopDefault(require('clsx'));
6
-
7
- function _extends() {
8
- _extends = Object.assign || function (target) {
9
- for (var i = 1; i < arguments.length; i++) {
10
- var source = arguments[i];
11
-
12
- for (var key in source) {
13
- if (Object.prototype.hasOwnProperty.call(source, key)) {
14
- target[key] = source[key];
15
- }
16
- }
17
- }
18
-
19
- return target;
20
- };
21
-
22
- return _extends.apply(this, arguments);
23
- }
24
-
25
- // A type of promise-like that resolves synchronously and supports only one observer
26
- const _Pact = /*#__PURE__*/(function() {
27
- function _Pact() {}
28
- _Pact.prototype.then = function(onFulfilled, onRejected) {
29
- const result = new _Pact();
30
- const state = this.s;
31
- if (state) {
32
- const callback = state & 1 ? onFulfilled : onRejected;
33
- if (callback) {
34
- try {
35
- _settle(result, 1, callback(this.v));
36
- } catch (e) {
37
- _settle(result, 2, e);
38
- }
39
- return result;
40
- } else {
41
- return this;
42
- }
43
- }
44
- this.o = function(_this) {
45
- try {
46
- const value = _this.v;
47
- if (_this.s & 1) {
48
- _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
49
- } else if (onRejected) {
50
- _settle(result, 1, onRejected(value));
51
- } else {
52
- _settle(result, 2, value);
53
- }
54
- } catch (e) {
55
- _settle(result, 2, e);
56
- }
57
- };
58
- return result;
59
- };
60
- return _Pact;
61
- })();
62
-
63
- // Settles a pact synchronously
64
- function _settle(pact, state, value) {
65
- if (!pact.s) {
66
- if (value instanceof _Pact) {
67
- if (value.s) {
68
- if (state & 1) {
69
- state = value.s;
70
- }
71
- value = value.v;
72
- } else {
73
- value.o = _settle.bind(null, pact, state);
74
- return;
75
- }
76
- }
77
- if (value && value.then) {
78
- value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
79
- return;
80
- }
81
- pact.s = state;
82
- pact.v = value;
83
- const observer = pact.o;
84
- if (observer) {
85
- observer(pact);
86
- }
87
- }
88
- }
89
-
90
- const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
91
-
92
- const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
93
-
94
- // Asynchronously implement a switch statement
95
- function _switch(discriminant, cases) {
96
- var dispatchIndex = -1;
97
- var awaitBody;
98
- outer: {
99
- for (var i = 0; i < cases.length; i++) {
100
- var test = cases[i][0];
101
- if (test) {
102
- var testValue = test();
103
- if (testValue && testValue.then) {
104
- break outer;
105
- }
106
- if (testValue === discriminant) {
107
- dispatchIndex = i;
108
- break;
109
- }
110
- } else {
111
- // Found the default case, set it as the pending dispatch case
112
- dispatchIndex = i;
113
- }
114
- }
115
- if (dispatchIndex !== -1) {
116
- do {
117
- var body = cases[dispatchIndex][1];
118
- while (!body) {
119
- dispatchIndex++;
120
- body = cases[dispatchIndex][1];
121
- }
122
- var result = body();
123
- if (result && result.then) {
124
- awaitBody = true;
125
- break outer;
126
- }
127
- var fallthroughCheck = cases[dispatchIndex][2];
128
- dispatchIndex++;
129
- } while (fallthroughCheck && !fallthroughCheck());
130
- return result;
131
- }
132
- }
133
- const pact = new _Pact();
134
- const reject = _settle.bind(null, pact, 2);
135
- (awaitBody ? result.then(_resumeAfterBody) : testValue.then(_resumeAfterTest)).then(void 0, reject);
136
- return pact;
137
- function _resumeAfterTest(value) {
138
- for (;;) {
139
- if (value === discriminant) {
140
- dispatchIndex = i;
141
- break;
142
- }
143
- if (++i === cases.length) {
144
- if (dispatchIndex !== -1) {
145
- break;
146
- } else {
147
- _settle(pact, 1, result);
148
- return;
149
- }
150
- }
151
- test = cases[i][0];
152
- if (test) {
153
- value = test();
154
- if (value && value.then) {
155
- value.then(_resumeAfterTest).then(void 0, reject);
156
- return;
157
- }
158
- } else {
159
- dispatchIndex = i;
160
- }
161
- }
162
- do {
163
- var body = cases[dispatchIndex][1];
164
- while (!body) {
165
- dispatchIndex++;
166
- body = cases[dispatchIndex][1];
167
- }
168
- var result = body();
169
- if (result && result.then) {
170
- result.then(_resumeAfterBody).then(void 0, reject);
171
- return;
172
- }
173
- var fallthroughCheck = cases[dispatchIndex][2];
174
- dispatchIndex++;
175
- } while (fallthroughCheck && !fallthroughCheck());
176
- _settle(pact, 1, result);
177
- }
178
- function _resumeAfterBody(result) {
179
- for (;;) {
180
- var fallthroughCheck = cases[dispatchIndex][2];
181
- if (!fallthroughCheck || fallthroughCheck()) {
182
- break;
183
- }
184
- dispatchIndex++;
185
- var body = cases[dispatchIndex][1];
186
- while (!body) {
187
- dispatchIndex++;
188
- body = cases[dispatchIndex][1];
189
- }
190
- result = body();
191
- if (result && result.then) {
192
- result.then(_resumeAfterBody).then(void 0, reject);
193
- return;
194
- }
195
- }
196
- _settle(pact, 1, result);
197
- }
198
- }
199
-
200
- var s = {"container":"_1Lxpd","paper":"_8Yd7S","pipe":"_3uH2i","card":"_xsi02","prev":"_KqFRp","next":"_1uQwZ","back":"_18Pcq","go":"_1nj1b","card__stop":"_3cLUl","content":"_2jwZj","button":"_2hTXI","button__next":"_2Z7EZ","button__prev":"_2Xedt","icon__button":"_2J4XS","dots":"_3MuXE","dot":"_3U2py","active":"_3sodH"};
201
-
202
- var SWIPE_TRANSITION_TIMEOUT = 400;
203
- var SWIPE_ON_EVENT_SPEED = 0.7;
204
-
205
- var getSwipes = function getSwipes(prev, current, next, swipes) {
206
- 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) {
207
- return swipes;
208
- }
209
-
210
- var result = [1, 2, 3].map(function (id) {
211
- var item = id === 1 ? _extends({}, prev) : id === 2 ? current : _extends({}, next);
212
- item.type = id === 1 ? 'prev' : id === 2 ? 'current' : 'next';
213
- return item;
214
- });
215
- return result;
216
- };
217
-
218
- var getDefaultSwipe = function getDefaultSwipe() {
219
- return {
220
- id: Math.ceil(Math.random() * 1000),
221
- children: React__default.createElement("div", null)
222
- };
223
- };
224
-
225
- var refs = {};
226
- var startClientX;
227
- var startClientY;
228
- var lastLeft;
229
- var animated = false;
230
- var prePrev = null;
231
- var postNext = null;
232
-
233
- var _defaultCurrent;
234
-
235
- var oldSwipes = [];
236
- var startTime = new Date().getTime();
237
- var Swiper = function Swiper(props) {
238
- var defaultCurrent = props.defaultCurrent,
239
- getNext = props.getNext,
240
- getPrev = props.getPrev,
241
- onSwipe = props.onSwipe,
242
- className = props.className,
243
- invitationAnimation = props.invitationAnimation,
244
- durationAnimation = props.durationAnimation,
245
- blockSwipe = props.blockSwipe,
246
- dots = props.dots;
247
-
248
- var _useState = React.useState(),
249
- current = _useState[0],
250
- setCurrent = _useState[1];
251
-
252
- var _useState2 = React.useState(),
253
- prev = _useState2[0],
254
- setPrev = _useState2[1];
255
-
256
- var _useState3 = React.useState(),
257
- next = _useState3[0],
258
- setNext = _useState3[1];
259
-
260
- var _useState4 = React.useState(0),
261
- windowWidth = _useState4[0],
262
- setWindowWidth = _useState4[1];
263
-
264
- var _useState5 = React.useState(0),
265
- height = _useState5[0],
266
- setHeight = _useState5[1];
267
-
268
- var _useState6 = React.useState(0),
269
- width = _useState6[0],
270
- setWidth = _useState6[1];
271
-
272
- var _useState7 = React.useState(0),
273
- _left = _useState7[0],
274
- _setLeft = _useState7[1];
275
-
276
- var _useState8 = React.useState(0),
277
- left = _useState8[0],
278
- setLeft = _useState8[1];
279
-
280
- var _useState9 = React.useState(),
281
- isMobile = _useState9[0],
282
- setIsMobile = _useState9[1];
283
-
284
- var _useState10 = React.useState(false),
285
- load = _useState10[0],
286
- setLoad = _useState10[1];
287
-
288
- var containerRef = React.useRef(null);
289
-
290
- if (typeof _defaultCurrent === 'undefined') {
291
- _defaultCurrent = defaultCurrent;
292
- }
293
-
294
- var swipes = React.useMemo(function () {
295
- return getSwipes(prev || getDefaultSwipe(), current || defaultCurrent, next || getDefaultSwipe(), oldSwipes);
296
- }, [next, prev, current]);
297
- oldSwipes = swipes;
298
-
299
- var getRef = function getRef(id) {
300
- refs[id] = refs[id] ? refs[id] : React.createRef();
301
- return refs[id];
302
- };
303
-
304
- var setGoClassHandler = function setGoClassHandler(_next, _prev) {
305
- var _getRef$current, _getRef$current2, _getRef$current3;
306
-
307
- (_getRef$current = getRef((_next === null || _next === void 0 ? void 0 : _next.id) || (next === null || next === void 0 ? void 0 : next.id) || 0).current) === null || _getRef$current === void 0 ? void 0 : _getRef$current.classList.add(s.go);
308
- (_getRef$current2 = getRef((_prev === null || _prev === void 0 ? void 0 : _prev.id) || (prev === null || prev === void 0 ? void 0 : prev.id) || 0).current) === null || _getRef$current2 === void 0 ? void 0 : _getRef$current2.classList.add(s.go);
309
- (_getRef$current3 = getRef((current === null || current === void 0 ? void 0 : current.id) || 0).current) === null || _getRef$current3 === void 0 ? void 0 : _getRef$current3.classList.add(s.go);
310
- setTimeout(function () {
311
- var _getRef$current4, _getRef$current5, _getRef$current6;
312
-
313
- (_getRef$current4 = getRef((_next === null || _next === void 0 ? void 0 : _next.id) || (next === null || next === void 0 ? void 0 : next.id) || 0).current) === null || _getRef$current4 === void 0 ? void 0 : _getRef$current4.classList.remove(s.go);
314
- (_getRef$current5 = getRef((_prev === null || _prev === void 0 ? void 0 : _prev.id) || (prev === null || prev === void 0 ? void 0 : prev.id) || 0).current) === null || _getRef$current5 === void 0 ? void 0 : _getRef$current5.classList.remove(s.go);
315
- (_getRef$current6 = getRef((current === null || current === void 0 ? void 0 : current.id) || 0).current) === null || _getRef$current6 === void 0 ? void 0 : _getRef$current6.classList.remove(s.go);
316
- }, SWIPE_TRANSITION_TIMEOUT);
317
- };
318
-
319
- var setBackClassHandler = function setBackClassHandler() {
320
- var _getRef$current7, _getRef$current8, _getRef$current9;
321
-
322
- (_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(s.back);
323
- (_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(s.back);
324
- (_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(s.back);
325
- setTimeout(function () {
326
- var _getRef$current10, _getRef$current11, _getRef$current12;
327
-
328
- (_getRef$current10 = getRef((next === null || next === void 0 ? void 0 : next.id) || 0).current) === null || _getRef$current10 === void 0 ? void 0 : _getRef$current10.classList.remove(s.back);
329
- (_getRef$current11 = getRef((prev === null || prev === void 0 ? void 0 : prev.id) || 0).current) === null || _getRef$current11 === void 0 ? void 0 : _getRef$current11.classList.remove(s.back);
330
- (_getRef$current12 = getRef((current === null || current === void 0 ? void 0 : current.id) || 0).current) === null || _getRef$current12 === void 0 ? void 0 : _getRef$current12.classList.remove(s.back);
331
- }, SWIPE_TRANSITION_TIMEOUT);
332
- };
333
-
334
- var wait = function wait(miliseconds) {
335
- try {
336
- return Promise.resolve(new Promise(function (resolve) {
337
- setTimeout(function () {
338
- resolve(0);
339
- }, miliseconds);
340
- })).then(function () {});
341
- } catch (e) {
342
- return Promise.reject(e);
343
- }
344
- };
345
-
346
- var setPreValues = function setPreValues(_p, _n) {
347
- if (_p) {
348
- getPrev((_p === null || _p === void 0 ? void 0 : _p.id) || 0).then(function (d) {
349
- prePrev = d;
350
- });
351
- }
352
-
353
- if (_n) {
354
- getNext((_n === null || _n === void 0 ? void 0 : _n.id) || 0).then(function (d) {
355
- postNext = d;
356
- });
357
- }
358
- };
359
-
360
- var swipe = function swipe(_ref) {
361
- var _lastLeft = _ref._lastLeft,
362
- _next = _ref._next,
363
- _prev = _ref._prev,
364
- speed = _ref.speed;
365
-
366
- try {
367
- var _temp7 = function _temp7(_result2) {
368
- if (_exit2) return _result2;
369
- setLoad(false);
370
- return 0;
371
- };
372
-
373
- var _exit2 = false;
374
- setLoad(true);
375
-
376
- var _startTime;
377
-
378
- var currentId = 0;
379
-
380
- var _temp8 = function () {
381
- if (Math.abs(_lastLeft) > width / 3 || speed !== undefined && speed > SWIPE_ON_EVENT_SPEED) {
382
- return function () {
383
- if (_lastLeft < 0) {
384
- var _temp9 = function _temp9() {
385
- return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - _startTime))).then(function () {
386
- setLeft(0);
387
- setPrev(current);
388
- setCurrent(_next || next);
389
- setNext(postNext);
390
- });
391
- };
392
-
393
- if ((next === null || next === void 0 ? void 0 : next.id) === null) {
394
- setBackClassHandler();
395
- setLeft(0);
396
- setLoad(false);
397
- _exit2 = true;
398
- return 1;
399
- }
400
-
401
- currentId = (_next === null || _next === void 0 ? void 0 : _next.id) || (next === null || next === void 0 ? void 0 : next.id);
402
-
403
- if (onSwipe !== undefined) {
404
- onSwipe(currentId);
405
- }
406
-
407
- setGoClassHandler(_next);
408
- setLeft(windowWidth * -1);
409
- _startTime = new Date().getTime();
410
-
411
- var _temp10 = function () {
412
- var _postNext;
413
-
414
- if ((next === null || next === void 0 ? void 0 : next.id) === ((_postNext = postNext) === null || _postNext === void 0 ? void 0 : _postNext.id)) {
415
- return Promise.resolve(new Promise(function (resolve) {
416
- var clear = setInterval(function () {
417
- var _postNext2;
418
-
419
- if ((next === null || next === void 0 ? void 0 : next.id) !== ((_postNext2 = postNext) === null || _postNext2 === void 0 ? void 0 : _postNext2.id)) {
420
- clearInterval(clear);
421
- resolve(0);
422
- }
423
- }, 0);
424
- })).then(function () {});
425
- }
426
- }();
427
-
428
- return _temp10 && _temp10.then ? _temp10.then(_temp9) : _temp9(_temp10);
429
- } else {
430
- var _temp11 = function _temp11() {
431
- return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT - (new Date().getTime() - _startTime))).then(function () {
432
- setLeft(0);
433
- setPrev(prePrev);
434
- setCurrent(_prev || prev);
435
- setNext(current);
436
- });
437
- };
438
-
439
- if ((prev === null || prev === void 0 ? void 0 : prev.id) === null) {
440
- setBackClassHandler();
441
- setLeft(0);
442
- setLoad(false);
443
- _exit2 = true;
444
- return 1;
445
- }
446
-
447
- currentId = (_prev === null || _prev === void 0 ? void 0 : _prev.id) || (prev === null || prev === void 0 ? void 0 : prev.id);
448
-
449
- if (onSwipe !== undefined) {
450
- onSwipe(currentId);
451
- }
452
-
453
- setGoClassHandler(undefined, _prev);
454
- setLeft(windowWidth);
455
- _startTime = new Date().getTime();
456
-
457
- var _temp12 = function () {
458
- var _prePrev;
459
-
460
- if ((prev === null || prev === void 0 ? void 0 : prev.id) === ((_prePrev = prePrev) === null || _prePrev === void 0 ? void 0 : _prePrev.id)) {
461
- return Promise.resolve(new Promise(function (resolve) {
462
- var clear = setInterval(function () {
463
- var _prePrev2;
464
-
465
- if ((prev === null || prev === void 0 ? void 0 : prev.id) !== ((_prePrev2 = prePrev) === null || _prePrev2 === void 0 ? void 0 : _prePrev2.id)) {
466
- clearInterval(clear);
467
- resolve(0);
468
- }
469
- }, 0);
470
- })).then(function () {});
471
- }
472
- }();
473
-
474
- return _temp12 && _temp12.then ? _temp12.then(_temp11) : _temp11(_temp12);
475
- }
476
- }();
477
- } else {
478
- setBackClassHandler();
479
- setLeft(0);
480
- setLoad(false);
481
- _exit2 = true;
482
- return 1;
483
- }
484
- }();
485
-
486
- return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(_temp7) : _temp7(_temp8));
487
- } catch (e) {
488
- return Promise.reject(e);
489
- }
490
- };
491
-
492
- var onTouchHandler = function onTouchHandler(name, e) {
493
- try {
494
- var _touches$, _touches$2;
495
-
496
- var _temp16 = function _temp16() {
497
- _interrupt2 = true;
498
- };
499
-
500
- var _interrupt2 = false;
501
- var touches = e.touches;
502
- var clientX = (_touches$ = touches[0]) === null || _touches$ === void 0 ? void 0 : _touches$.clientX;
503
- var clientY = (_touches$2 = touches[0]) === null || _touches$2 === void 0 ? void 0 : _touches$2.clientY;
504
- startClientX = startClientX || 0;
505
- startClientY = startClientY || 0;
506
- var absX = 0;
507
- var absY = 0;
508
-
509
- var _temp17 = _switch(name, [[function () {
510
- return 'onTouchStart';
511
- }, function () {
512
- startClientX = clientX;
513
- startClientY = clientY;
514
- lastLeft = _left;
515
- startTime = new Date().getTime();
516
- _interrupt2 = true;
517
- }], [function () {
518
- return 'onTouchMove';
519
- }, function () {
520
- if (!blockSwipe) {
521
- absY = Math.abs(startClientY - clientY);
522
- absX = Math.abs(startClientX - clientX);
523
-
524
- if (absX > absY) {
525
- lastLeft = _left - (startClientX - clientX);
526
- setLeft(lastLeft);
527
- }
528
- }
529
-
530
- _interrupt2 = true;
531
- }], [function () {
532
- return 'onTouchEnd';
533
- }, function () {
534
- var _temp13 = function () {
535
- if (!blockSwipe) {
536
- return Promise.resolve(swipe({
537
- _lastLeft: lastLeft,
538
- speed: Math.abs(lastLeft / (new Date().getTime() - startTime))
539
- })).then(function () {});
540
- }
541
- }();
542
-
543
- return _temp13 && _temp13.then ? _temp13.then(_temp16) : _temp16(_temp13);
544
- }], []]);
545
-
546
- return Promise.resolve(_temp17 && _temp17.then ? _temp17.then(function () {}) : void 0);
547
- } catch (e) {
548
- return Promise.reject(e);
549
- }
550
- };
551
-
552
- var onTouchWrapper = function onTouchWrapper(name) {
553
- return function (e) {
554
- onTouchHandler(name, e);
555
- };
556
- };
557
-
558
- var clickHandler = function clickHandler(origin) {
559
- var isNext = origin === 'next';
560
- return function () {
561
- try {
562
- var coeff = isNext ? -1 : 1;
563
- var leftVal = width * coeff;
564
-
565
- if (isNext) {
566
- setGoClassHandler();
567
- } else {
568
- setBackClassHandler();
569
- }
570
-
571
- return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT)).then(function () {
572
- return Promise.resolve(swipe({
573
- _lastLeft: leftVal
574
- })).then(function () {
575
- return 0;
576
- });
577
- });
578
- } catch (e) {
579
- return Promise.reject(e);
580
- }
581
- };
582
- };
583
-
584
- var clickNextHandler = clickHandler('next');
585
- var clickPrevHandler = clickHandler('prev');
586
-
587
- var resizeHandler = function resizeHandler() {
588
- var _containerRef$current, _containerRef$current2, _containerRef$current3, _containerRef$current4, _containerRef$current5, _containerRef$current6, _containerRef$current7, _containerRef$current8, _containerRef$current9;
589
-
590
- var _width = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.parentElement) === null || _containerRef$current2 === void 0 ? void 0 : (_containerRef$current3 = _containerRef$current2.getBoundingClientRect()) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.width;
591
-
592
- var _height = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : (_containerRef$current5 = _containerRef$current4.parentElement) === null || _containerRef$current5 === void 0 ? void 0 : (_containerRef$current6 = _containerRef$current5.getBoundingClientRect()) === null || _containerRef$current6 === void 0 ? void 0 : _containerRef$current6.height;
593
-
594
- var __left = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current7 = containerRef.current) === null || _containerRef$current7 === void 0 ? void 0 : (_containerRef$current8 = _containerRef$current7.parentElement) === null || _containerRef$current8 === void 0 ? void 0 : (_containerRef$current9 = _containerRef$current8.getBoundingClientRect()) === null || _containerRef$current9 === void 0 ? void 0 : _containerRef$current9.left;
595
-
596
- var _windowWidth = document.body.clientWidth;
597
-
598
- if (_width && _height) {
599
- setWidth(_width);
600
- setHeight(_height);
601
- }
602
-
603
- if (__left) {
604
- setLeft(__left);
605
- }
606
-
607
- if (_windowWidth) {
608
- setWindowWidth(_windowWidth);
609
- }
610
- };
611
-
612
- var infitationAnimationHandler = function infitationAnimationHandler(shift) {
613
- try {
614
- if (shift < 0) {
615
- setGoClassHandler();
616
- } else {
617
- setBackClassHandler();
618
- }
619
-
620
- setLeft(shift);
621
- return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT)).then(function () {
622
- if (shift < 0) {
623
- setBackClassHandler();
624
- } else {
625
- setGoClassHandler();
626
- }
627
-
628
- setLeft(0);
629
- return Promise.resolve(wait(SWIPE_TRANSITION_TIMEOUT)).then(function () {});
630
- });
631
- } catch (e) {
632
- return Promise.reject(e);
633
- }
634
- };
635
-
636
- var setStartCards = function setStartCards() {
637
- try {
638
- return Promise.resolve(getNext(defaultCurrent.id || 0)).then(function (_n) {
639
- return Promise.resolve(getPrev(defaultCurrent.id || 0)).then(function (_p) {
640
- setCurrent(defaultCurrent);
641
- setPrev(_p);
642
- setNext(_n);
643
- return Promise.resolve(getPrev(_p.id || 0)).then(function (_getPrev) {
644
- prePrev = _getPrev;
645
- return Promise.resolve(getNext(_n.id || 0)).then(function (_getNext) {
646
- postNext = _getNext;
647
- _defaultCurrent = defaultCurrent;
648
- setLoad(false);
649
- });
650
- });
651
- });
652
- });
653
- } catch (e) {
654
- return Promise.reject(e);
655
- }
656
- };
657
-
658
- var startInvitationAnimation = function startInvitationAnimation(prev, next) {
659
- try {
660
- var _temp21 = function _temp21() {
661
- var _temp18 = function () {
662
- if (next.id) {
663
- return Promise.resolve(infitationAnimationHandler(windowWidth / 5.5 * -1)).then(function () {});
664
- }
665
- }();
666
-
667
- if (_temp18 && _temp18.then) return _temp18.then(function () {});
668
- };
669
-
670
- var _temp22 = function () {
671
- if (prev.id) {
672
- return Promise.resolve(infitationAnimationHandler(windowWidth / 5.5)).then(function () {});
673
- }
674
- }();
675
-
676
- return Promise.resolve(_temp22 && _temp22.then ? _temp22.then(_temp21) : _temp21(_temp22));
677
- } catch (e) {
678
- return Promise.reject(e);
679
- }
680
- };
681
-
682
- var clickDotHandler = function clickDotHandler(e) {
683
- try {
684
- var target = e.target;
685
- var tabindex = target === null || target === void 0 ? void 0 : target.getAttribute('tabindex');
686
- var active = parseInt(tabindex, 10);
687
- var currId = (current === null || current === void 0 ? void 0 : current.id) || 0;
688
-
689
- var _temp24 = function () {
690
- if (currId < active) {
691
- return Promise.resolve(getNext(active - 1)).then(function (next) {
692
- setNext(next);
693
- return Promise.resolve(getPrev((next === null || next === void 0 ? void 0 : next.id) || 0)).then(function (prev) {
694
- return Promise.resolve(swipe({
695
- _lastLeft: -1000,
696
- _prev: prev,
697
- _next: next
698
- })).then(function () {
699
- return Promise.resolve(getNext((next === null || next === void 0 ? void 0 : next.id) || 0)).then(function (_getNext2) {
700
- postNext = _getNext2;
701
- return Promise.resolve(getPrev((prev === null || prev === void 0 ? void 0 : prev.id) || 0)).then(function (_getPrev2) {
702
- prePrev = _getPrev2;
703
- setPrev(prev);
704
- });
705
- });
706
- });
707
- });
708
- });
709
- } else {
710
- return Promise.resolve(getPrev(active + 1)).then(function (prev) {
711
- setPrev(prev);
712
- return Promise.resolve(getNext((prev === null || prev === void 0 ? void 0 : prev.id) || 0)).then(function (next) {
713
- return Promise.resolve(swipe({
714
- _lastLeft: 1000,
715
- _prev: prev,
716
- _next: next
717
- })).then(function () {
718
- return Promise.resolve(getNext((next === null || next === void 0 ? void 0 : next.id) || 0)).then(function (_getNext3) {
719
- postNext = _getNext3;
720
- return Promise.resolve(getPrev((prev === null || prev === void 0 ? void 0 : prev.id) || 0)).then(function (_getPrev3) {
721
- prePrev = _getPrev3;
722
- setNext(next);
723
- });
724
- });
725
- });
726
- });
727
- });
728
- }
729
- }();
730
-
731
- return Promise.resolve(_temp24 && _temp24.then ? _temp24.then(function () {}) : void 0);
732
- } catch (e) {
733
- return Promise.reject(e);
734
- }
735
- };
736
-
737
- React.useEffect(function () {
738
- var _containerRef$current10, _containerRef$current11, _containerRef$current12, _containerRef$current13, _containerRef$current14, _containerRef$current15, _containerRef$current16, _containerRef$current17, _containerRef$current18, _current$nextRef, _current$closeRef;
739
-
740
- var clearAnimate;
741
-
742
- if (durationAnimation) {
743
- clearAnimate = setInterval(function () {
744
- clickNextHandler();
745
- }, durationAnimation);
746
- }
747
-
748
- var _width = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current10 = containerRef.current) === null || _containerRef$current10 === void 0 ? void 0 : (_containerRef$current11 = _containerRef$current10.parentElement) === null || _containerRef$current11 === void 0 ? void 0 : (_containerRef$current12 = _containerRef$current11.getBoundingClientRect()) === null || _containerRef$current12 === void 0 ? void 0 : _containerRef$current12.width;
749
-
750
- var _height = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current13 = containerRef.current) === null || _containerRef$current13 === void 0 ? void 0 : (_containerRef$current14 = _containerRef$current13.parentElement) === null || _containerRef$current14 === void 0 ? void 0 : (_containerRef$current15 = _containerRef$current14.getBoundingClientRect()) === null || _containerRef$current15 === void 0 ? void 0 : _containerRef$current15.height;
751
-
752
- 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;
753
-
754
- var _windowWidth = document.body.clientWidth;
755
- var buttonNext = current === null || current === void 0 ? void 0 : (_current$nextRef = current.nextRef) === null || _current$nextRef === void 0 ? void 0 : _current$nextRef.current;
756
- var buttonClose = current === null || current === void 0 ? void 0 : (_current$closeRef = current.closeRef) === null || _current$closeRef === void 0 ? void 0 : _current$closeRef.current;
757
- buttonNext === null || buttonNext === void 0 ? void 0 : buttonNext.addEventListener('click', clickNextHandler);
758
- buttonClose === null || buttonClose === void 0 ? void 0 : buttonClose.addEventListener('click', clickNextHandler);
759
-
760
- if (_width && !width && _height && !height) {
761
- setWidth(_width);
762
- setHeight(_height);
763
- }
764
-
765
- if (__left && !left) {
766
- _setLeft(__left);
767
- }
768
-
769
- if (!windowWidth && _windowWidth) {
770
- setWindowWidth(_windowWidth);
771
- }
772
-
773
- if (!current || !prev || !next || _defaultCurrent !== defaultCurrent) {
774
- setStartCards();
775
- }
776
-
777
- if (invitationAnimation && width && !animated) {
778
- if (prev && next) {
779
- animated = true;
780
- startInvitationAnimation(prev, next);
781
- }
782
- }
783
-
784
- if (typeof isMobile === 'undefined') {
785
- var _navigator;
786
-
787
- setIsMobile('ontouchstart' in window || typeof ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.msMaxTouchPoints) !== 'undefined');
788
- }
789
-
790
- setPreValues(prev, next);
791
- window.addEventListener('resize', resizeHandler);
792
- return function () {
793
- if (clearAnimate) {
794
- clearInterval(clearAnimate);
795
- }
796
-
797
- window.removeEventListener('resize', resizeHandler);
798
- buttonNext === null || buttonNext === void 0 ? void 0 : buttonNext.removeEventListener('click', clickNextHandler);
799
- buttonClose === null || buttonClose === void 0 ? void 0 : buttonClose.removeEventListener('click', clickNextHandler);
800
- };
801
- }, [next, defaultCurrent]);
802
- return React__default.createElement("div", {
803
- className: s.container,
804
- ref: containerRef
805
- }, swipes.map(function (item) {
806
- var _item$id;
807
-
808
- return React__default.createElement(React.Fragment, {
809
- key: item.id
810
- }, item.id !== null && item.children !== null && width && React__default.createElement("div", {
811
- onTouchMove: onTouchWrapper('onTouchMove'),
812
- onTouchStart: onTouchWrapper('onTouchStart'),
813
- onTouchEnd: onTouchWrapper('onTouchEnd'),
814
- id: (_item$id = item.id) === null || _item$id === void 0 ? void 0 : _item$id.toString(),
815
- style: item.type === 'current' ? {
816
- width: width,
817
- height: height,
818
- left: left
819
- } : item.type === 'prev' ? {
820
- width: width,
821
- height: height,
822
- left: left - window.innerWidth
823
- } : {
824
- width: width,
825
- height: height,
826
- left: left + window.innerWidth
827
- },
828
- className: clsx(s.card, item.type === 'prev' ? s.prev : item.type === 'next' ? s.next : ''),
829
- ref: getRef(item.id)
830
- }, React__default.createElement("div", {
831
- className: clsx(s.content, className)
832
- }, item.children)), item.id === null && React__default.createElement("div", {
833
- style: item.type === 'current' ? {
834
- width: width,
835
- height: height,
836
- left: left
837
- } : item.type === 'prev' ? {
838
- width: width,
839
- height: height,
840
- left: left - windowWidth
841
- } : {
842
- width: width,
843
- height: height,
844
- left: left + windowWidth
845
- },
846
- className: clsx(s.card, item.type === 'prev' ? s.prev : item.type === 'next' ? s.next : '')
847
- }, React__default.createElement("svg", {
848
- xmlns: "http://www.w3.org/2000/svg",
849
- height: "24px",
850
- viewBox: "0 0 24 24",
851
- width: "24px",
852
- fill: "#000000"
853
- }, React__default.createElement("path", {
854
- d: "M0 0h24v24H0V0z",
855
- fill: "none"
856
- }), React__default.createElement("path", {
857
- d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z"
858
- }))));
859
- }), typeof isMobile !== 'undefined' && !isMobile && (prev === null || prev === void 0 ? void 0 : prev.id) !== null && React__default.createElement("div", {
860
- className: clsx(s.button, s.button__prev)
861
- }, React__default.createElement("button", {
862
- className: s.icon__button,
863
- type: "button",
864
- disabled: load || isMobile,
865
- onClick: clickPrevHandler
866
- }, React__default.createElement("svg", {
867
- xmlns: "http://www.w3.org/2000/svg",
868
- height: "24px",
869
- viewBox: "0 0 24 24",
870
- width: "24px",
871
- fill: "#000000"
872
- }, React__default.createElement("path", {
873
- d: "M0 0h24v24H0V0z",
874
- fill: "none"
875
- }), React__default.createElement("path", {
876
- d: "M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"
877
- })))), typeof isMobile !== 'undefined' && !isMobile && (next === null || next === void 0 ? void 0 : next.id) !== null && React__default.createElement("div", {
878
- className: clsx(s.button, s.button__next)
879
- }, React__default.createElement("button", {
880
- className: s.icon__button,
881
- type: "button",
882
- disabled: load || isMobile,
883
- onClick: clickNextHandler
884
- }, React__default.createElement("svg", {
885
- xmlns: "http://www.w3.org/2000/svg",
886
- height: "24px",
887
- viewBox: "0 0 24 24",
888
- width: "24px",
889
- fill: "#000000"
890
- }, React__default.createElement("path", {
891
- d: "M0 0h24v24H0V0z",
892
- fill: "none"
893
- }), React__default.createElement("path", {
894
- d: "M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"
895
- })))), dots && React__default.createElement("div", {
896
- className: s.dots
897
- }, dots.list.map(function (item) {
898
- return React__default.createElement("div", {
899
- role: "button",
900
- onClick: clickDotHandler,
901
- tabIndex: item,
902
- key: item,
903
- className: clsx(s.dot, (current === null || current === void 0 ? void 0 : current.id) === item ? s.active : '')
904
- });
905
- })));
906
- };
907
- Swiper.defaultProps = {
908
- className: ''
909
- };
910
-
911
- exports.SWIPE_ON_EVENT_SPEED = SWIPE_ON_EVENT_SPEED;
912
- exports.SWIPE_TRANSITION_TIMEOUT = SWIPE_TRANSITION_TIMEOUT;
913
- exports.Swiper = Swiper;
914
- //# sourceMappingURL=index.js.map
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ !function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n(require("react"));else if("function"==typeof define&&define.amd)define(["react"],n);else{var t="object"==typeof exports?n(require("react")):n(e.react);for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(global,(e=>(()=>{"use strict";var n={156:n=>{n.exports=e}},t={};function i(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return i.d(n,{a:n}),n},i.d=(e,n)=>{for(var t in n)i.o(n,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},i.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{i.r(r),i.d(r,{SWIPE_ON_EVENT_SPEED:()=>y,SWIPE_TRANSITION_TIMEOUT:()=>E,Swiper:()=>_});var e=i(156),n=i.n(e);function t(e){var n,i,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e))for(n=0;n<e.length;n++)e[n]&&(i=t(e[n]))&&(r&&(r+=" "),r+=i);else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function o(){for(var e,n,i=0,r="";i<arguments.length;)(e=arguments[i++])&&(n=t(e))&&(r&&(r+=" "),r+=n);return r}const u="ajuBL3q0nyu2Zg1CK1CW",l="ORWaQ8ChxgR6YeBupUJg",c="StX1PugTKJCsVzFSl98K",d="RQKC4oDJ6ZH3FNeIdEMl",a="T52hGlv4InwunAWuRX7g",s="Ed7WmQrT2TLC_IsI2LAT",v="_TjajQy8som3UnbaMCpY";var f,h,p,m,w=function(){return w=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e},w.apply(this,arguments)},b=function(e,n,t,i){return new(t||(t=Promise))((function(r,o){function u(e){try{c(i.next(e))}catch(e){o(e)}}function l(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(u,l)}c((i=i.apply(e,n||[])).next())}))},g=function(e,n){var t,i,r,o,u={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(l){return function(c){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(u=0)),u;)try{if(t=1,i&&(r=2&l[0]?i.return:l[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,l[1])).done)return r;switch(i=0,r&&(l=[2&l[0],r.value]),l[0]){case 0:case 1:r=l;break;case 4:return u.label++,{value:l[1],done:!1};case 5:u.label++,i=l[1],l=[0];continue;case 7:l=u.ops.pop(),u.trys.pop();continue;default:if(!((r=(r=u.trys).length>0&&r[r.length-1])||6!==l[0]&&2!==l[0])){u=0;continue}if(3===l[0]&&(!r||l[1]>r[0]&&l[1]<r[3])){u.label=l[1];break}if(6===l[0]&&u.label<r[1]){u.label=r[1],r=l;break}if(r&&u.label<r[2]){u.label=r[2],u.ops.push(l);break}r[2]&&u.ops.pop(),u.trys.pop();continue}l=n.call(e,u)}catch(e){l=[6,e],i=0}finally{t=r=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,c])}}},E=400,y=.7,x=function(){return{id:Math.ceil(1e3*Math.random()),children:n().createElement("div",null)}},M={},S=!1,L=[],T=(new Date).getTime(),_=function(t){var i=t.defaultCurrent,r=t.getNext,_=t.getPrev,N=t.onSwipe,P=t.className,C=t.invitationAnimation,j=t.durationAnimation,R=t.blockSwipe,I=t.dots,k=(0,e.useState)(),z=k[0],B=k[1],O=(0,e.useState)(),A=O[0],W=O[1],D=(0,e.useState)(),F=D[0],G=D[1],H=(0,e.useState)(),K=H[0],Q=H[1],V=(0,e.useState)(),q=V[0],J=V[1],Y=(0,e.useState)(0),U=Y[0],X=Y[1],Z=(0,e.useState)(0),$=Z[0],ee=Z[1],ne=(0,e.useState)(0),te=ne[0],ie=ne[1],re=(0,e.useState)(0),oe=re[0],ue=re[1],le=(0,e.useState)(0),ce=le[0],de=le[1],ae=(0,e.useState)(),se=ae[0],ve=ae[1],fe=(0,e.useState)(!1),he=fe[0],pe=fe[1],me=(0,e.useRef)(null);void 0===m&&(m=i);var we=(0,e.useMemo)((function(){return function(e,n,t,i){return(null==e?void 0:e.id)!==(null==n?void 0:n.id)&&(null==n?void 0:n.id)!==(null==t?void 0:t.id)&&(null==t?void 0:t.id)!==(null==e?void 0:e.id)||!i.length?[1,2,3].map((function(i){var r=1===i?w({},e):2===i?n:w({},t);return r.type=1===i?"prev":2===i?"current":"next",r})):i}(A||x(),z||i,F||x(),L)}),[F,A,z]);L=we;var be=function(n){return M[n]=M[n]?M[n]:(0,e.createRef)(),M[n]},ge=(0,e.useMemo)((function(){return function(e,n){var t,i,r;null===(t=be((null==e?void 0:e.id)||(null==F?void 0:F.id)||0).current)||void 0===t||t.classList.add(a),null===(i=be((null==n?void 0:n.id)||(null==A?void 0:A.id)||0).current)||void 0===i||i.classList.add(a),null===(r=be((null==z?void 0:z.id)||0).current)||void 0===r||r.classList.add(a),setTimeout((function(){var t,i,r;null===(t=be((null==e?void 0:e.id)||(null==F?void 0:F.id)||0).current)||void 0===t||t.classList.remove(a),null===(i=be((null==n?void 0:n.id)||(null==A?void 0:A.id)||0).current)||void 0===i||i.classList.remove(a),null===(r=be((null==z?void 0:z.id)||0).current)||void 0===r||r.classList.remove(a)}),E)}}),[null==z?void 0:z.id,null==F?void 0:F.id,null==A?void 0:A.id]),Ee=(0,e.useMemo)((function(){return function(){var e,n,t;null===(e=be((null==F?void 0:F.id)||0).current)||void 0===e||e.classList.add(d),null===(n=be((null==A?void 0:A.id)||0).current)||void 0===n||n.classList.add(d),null===(t=be((null==z?void 0:z.id)||0).current)||void 0===t||t.classList.add(d),setTimeout((function(){var e,n,t;null===(e=be((null==F?void 0:F.id)||0).current)||void 0===e||e.classList.remove(d),null===(n=be((null==A?void 0:A.id)||0).current)||void 0===n||n.classList.remove(d),null===(t=be((null==z?void 0:z.id)||0).current)||void 0===t||t.classList.remove(d)}),E)}}),[null==z?void 0:z.id,null==F?void 0:F.id,null==A?void 0:A.id]),ye=function(e){return b(void 0,void 0,void 0,(function(){return g(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n){setTimeout((function(){n(0)}),e)}))];case 1:return n.sent(),[2]}}))}))},xe=(0,e.useMemo)((function(){return function(e,n){e&&_((null==e?void 0:e.id)||0).then((function(e){Q(e)})),n&&r((null==n?void 0:n.id)||0).then((function(e){J(e)}))}}),[r,_]),Me=(0,e.useMemo)((function(){return function(){Ee(),de(0),pe(!1)}}),[Ee,de,pe]),Se=(0,e.useMemo)((function(){return function(e,n,t){ge(e,n),de(t)}}),[ge]),Le=(0,e.useMemo)((function(){return function(e){var n=e._prev,t=e._current,i=e._next;de(0),W(n),B(t),G(i)}}),[]),Te=(0,e.useMemo)((function(){return function(e,n,t){var i=e.newNext,r=e.newPrev,o=e.coeff;return b(void 0,void 0,void 0,(function(){return g(this,(function(e){switch(e.label){case 0:return null===(null==n?void 0:n.id)||null===(null==t?void 0:t.id)?(Me(),[2,1]):(void 0!==N&&N((null==n?void 0:n.id)||(null==t?void 0:t.id)),Se(n,t,U*o),[4,ye(E)]);case 1:return e.sent(),Le({_prev:r,_current:n||t,_next:i}),[2,0]}}))}))}}),[Le,Me,N,Se,U]),_e=(0,e.useMemo)((function(){return function(e){var n=e._lastLeft,t=e._next,i=e._prev,r=e.speed;return b(void 0,void 0,void 0,(function(){return g(this,(function(e){switch(e.label){case 0:return pe(!0),Math.abs(n)>te/3||void 0!==r&&r>y?n<0?[4,Te({newPrev:z,newNext:q,coeff:-1},t,void 0)]:[3,2]:[3,5];case 1:return e.sent(),[3,4];case 2:return[4,Te({newPrev:K,newNext:z,coeff:1},void 0,i)];case 3:e.sent(),e.label=4;case 4:return[3,6];case 5:Me(),e.label=6;case 6:return pe(!1),[2,0]}}))}))}}),[z,Me,te,K,q,Te]),Ne=(0,e.useMemo)((function(){return function(e,n){return b(void 0,void 0,void 0,(function(){var t,i,r,o,u,l;return g(this,(function(c){switch(c.label){case 0:switch(t=n.touches,i=null===(u=t[0])||void 0===u?void 0:u.clientX,r=null===(l=t[0])||void 0===l?void 0:l.clientY,f=f||0,h=h||0,o=0,e){case"onTouchStart":return[3,1];case"onTouchMove":return[3,2];case"onTouchEnd":return[3,3]}return[3,6];case 1:return f=i,h=r,p=oe,T=(new Date).getTime(),[3,6];case 2:return R||(o=Math.abs(h-r),Math.abs(f-i)>o&&de(p=oe-(f-i))),[3,6];case 3:return R?[3,5]:[4,_e({_lastLeft:p,speed:Math.abs(p/((new Date).getTime()-T)),_next:F,_prev:A})];case 4:c.sent(),c.label=5;case 5:return[3,6];case 6:return[2]}}))}))}}),[oe,R,_e,F,A]),Pe=function(e){return function(n){Ne(e,n)}},Ce=(0,e.useMemo)((function(){return function(e){var n="next"===e;return function(){return b(void 0,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return e=te*(n?-1:1),n?ge():Ee(),[4,ye(E)];case 1:return t.sent(),[4,_e({_lastLeft:e,_next:F,_prev:A})];case 2:return t.sent(),[2,0]}}))}))}}}),[Ee,ge,_e,te,F,A]),je=Ce("next"),Re=Ce("prev"),Ie=(0,e.useMemo)((function(){return function(e){return b(void 0,void 0,void 0,(function(){return g(this,(function(n){switch(n.label){case 0:return e<0?ge():Ee(),de(e),[4,ye(E)];case 1:return n.sent(),e<0?Ee():ge(),de(0),[4,ye(E)];case 2:return n.sent(),[2]}}))}))}}),[Ee,ge]),ke=(0,e.useMemo)((function(){return function(){return b(void 0,void 0,void 0,(function(){var e,n;return g(this,(function(t){switch(t.label){case 0:return[4,r(i.id||0)];case 1:return e=t.sent(),[4,_(i.id||0)];case 2:return n=t.sent(),B(i),W(n),G(e),m=i,pe(!1),[2]}}))}))}}),[i,r,_]),ze=(0,e.useMemo)((function(){return function(e,n){return b(void 0,void 0,void 0,(function(){return g(this,(function(t){switch(t.label){case 0:return e.id?[4,Ie(U/5.5)]:[3,2];case 1:t.sent(),t.label=2;case 2:return n.id?[4,Ie(U/5.5*-1)]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))}}),[Ie,U]),Be=(0,e.useMemo)((function(){return function(e){return b(void 0,void 0,void 0,(function(){var n,t,i,o,u,l,c;return g(this,(function(d){switch(d.label){case 0:return n=e.target,t=null==n?void 0:n.getAttribute("tabindex"),i=parseInt(t,10),(o=(null==z?void 0:z.id)||0)!==(null==F?void 0:F.id)?[3,1]:(u=F,c=q,l=z,[3,10]);case 1:return o!==(null==A?void 0:A.id)?[3,2]:(u=A,c=z,l=K,[3,10]);case 2:return o!==(null==K?void 0:K.id)?[3,4]:(u=K,c=A,[4,_(null==K?void 0:K.id)]);case 3:return l=d.sent(),[3,10];case 4:return o!==(null==q?void 0:q.id)?[3,6]:(u=q,l=F,[4,_(null==q?void 0:q.id)]);case 5:return c=d.sent(),[3,10];case 6:return[4,r(i-1)];case 7:return u=d.sent(),[4,r((null==u?void 0:u.id)||0)];case 8:return c=d.sent(),[4,_((null==u?void 0:u.id)||0)];case 9:l=d.sent(),d.label=10;case 10:return o<i?[4,Te({newPrev:l,newNext:c,coeff:-1},u,void 0)]:[3,12];case 11:return d.sent(),[3,14];case 12:return[4,Te({newPrev:l,newNext:c,coeff:1},void 0,u)];case 13:d.sent(),d.label=14;case 14:return[2]}}))}))}}),[r,_,Te,z,F,q,K,A]);return(0,e.useEffect)((function(){var e,n,t=null===(e=null==z?void 0:z.nextRef)||void 0===e?void 0:e.current,i=null===(n=null==z?void 0:z.closeRef)||void 0===n?void 0:n.current;return null==t||t.addEventListener("click",je),null==i||i.addEventListener("click",je),function(){null==t||t.removeEventListener("click",je),null==i||i.removeEventListener("click",je)}}),[je,z]),(0,e.useEffect)((function(){var e,n,t,i,r,o,u=null===(t=null===(n=null===(e=null==me?void 0:me.current)||void 0===e?void 0:e.parentElement)||void 0===n?void 0:n.getBoundingClientRect())||void 0===t?void 0:t.width,l=null===(o=null===(r=null===(i=null==me?void 0:me.current)||void 0===i?void 0:i.parentElement)||void 0===r?void 0:r.getBoundingClientRect())||void 0===o?void 0:o.height;u&&!te&&l&&!$&&(ie(u),ee(l))}),[me,te,$]),(0,e.useEffect)((function(){var e,n,t,i=null===(t=null===(n=null===(e=null==me?void 0:me.current)||void 0===e?void 0:e.parentElement)||void 0===n?void 0:n.getBoundingClientRect())||void 0===t?void 0:t.left;i&&!ce&&ue(i)}),[me,ce]),(0,e.useEffect)((function(){var e;return j&&(e=setInterval((function(){je()}),j)),function(){e&&clearInterval(e)}}),[j,je]),(0,e.useEffect)((function(){z&&A&&F&&m===i||ke()}),[z,F,A,i,ke]),(0,e.useEffect)((function(){var e=document.body.clientWidth;!U&&e&&X(e)}),[U]),(0,e.useEffect)((function(){C&&te&&!S&&A&&F&&(S=!0,ze(A,F))}),[C,F,A,ze,te]),(0,e.useEffect)((function(){var e=function(){var e,n,t,i,r,o,u,l,c,d=null===(t=null===(n=null===(e=null==me?void 0:me.current)||void 0===e?void 0:e.parentElement)||void 0===n?void 0:n.getBoundingClientRect())||void 0===t?void 0:t.width,a=null===(o=null===(r=null===(i=null==me?void 0:me.current)||void 0===i?void 0:i.parentElement)||void 0===r?void 0:r.getBoundingClientRect())||void 0===o?void 0:o.height,s=null===(c=null===(l=null===(u=null==me?void 0:me.current)||void 0===u?void 0:u.parentElement)||void 0===l?void 0:l.getBoundingClientRect())||void 0===c?void 0:c.left,v=document.body.clientWidth;d&&a&&(ie(d),ee(a)),s&&de(s),v&&X(v)};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[]),(0,e.useEffect)((function(){void 0===se&&ve("ontouchstart"in window||void 0!==(null===navigator||void 0===navigator?void 0:navigator.msMaxTouchPoints))}),[se]),(0,e.useEffect)((function(){xe(A,F)}),[A,F,xe]),n().createElement("div",{className:"uuonHvf1QSzDHOB9f1AR",ref:me},we.map((function(t){var i;return n().createElement(e.Fragment,{key:t.id},null!==t.id&&null!==t.children&&te&&n().createElement("div",{onTouchMove:Pe("onTouchMove"),onTouchStart:Pe("onTouchStart"),onTouchEnd:Pe("onTouchEnd"),id:null===(i=t.id)||void 0===i?void 0:i.toString(),style:"current"===t.type?{width:te,height:$,left:ce}:"prev"===t.type?{width:te,height:$,left:ce-window.innerWidth}:{width:te,height:$,left:ce+window.innerWidth},className:o(u,"prev"===t.type?l:"next"===t.type?c:""),ref:be(t.id)},n().createElement("div",{className:o("LqWEfhxfAfxSGx6v34FP",P)},t.children)),null===t.id&&n().createElement("div",{style:"current"===t.type?{width:te,height:$,left:ce}:"prev"===t.type?{width:te,height:$,left:ce-U}:{width:te,height:$,left:ce+U},className:o(u,"prev"===t.type?l:"next"===t.type?c:"")},n().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},n().createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),n().createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z"}))))})),void 0!==se&&!se&&null!==(null==A?void 0:A.id)&&n().createElement("div",{className:o(s,"KEpbCBSmtj3t84IdATjJ")},n().createElement("button",{className:v,type:"button",disabled:he||se,onClick:Re},n().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},n().createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),n().createElement("path",{d:"M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"})))),void 0!==se&&!se&&null!==(null==F?void 0:F.id)&&n().createElement("div",{className:o(s,"z11IafMuVtQrhpJc1uDS")},n().createElement("button",{className:v,type:"button",disabled:he||se,onClick:je},n().createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},n().createElement("path",{d:"M0 0h24v24H0V0z",fill:"none"}),n().createElement("path",{d:"M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"})))),I&&n().createElement("div",{className:"XLmbqLYlGGoFdjflPx0m"},I.list.map((function(e){return n().createElement("div",{role:"button",onClick:Be,tabIndex:e,key:e,className:o("oNRB_t8bPbx9h5hKcGP5",(null==z?void 0:z.id)===e?"Z3Oyb2UE_zwiancYA_Fd":"")})}))))};_.defaultProps={className:""}})(),r})()));
3
+ //# sourceMappingURL=index.js.map