-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.js
2918 lines (2916 loc) · 81.8 KB
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* shortcodes.js v1.0.2 | https://github.com/stamat/shortcodes.js | MIT License */
(() => {
// node_modules/@glidejs/glide/dist/glide.esm.js
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function(obj2) {
return typeof obj2;
};
} else {
_typeof = function(obj2) {
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor)
descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps)
_defineProperties(Constructor.prototype, protoProps);
if (staticProps)
_defineProperties(Constructor, staticProps);
return Constructor;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass)
_setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
return o2.__proto__ || Object.getPrototypeOf(o2);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
o2.__proto__ = p2;
return o2;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct)
return false;
if (Reflect.construct.sham)
return false;
if (typeof Proxy === "function")
return true;
try {
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
} else if (call !== void 0) {
throw new TypeError("Derived constructors may only return object or undefined");
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived), result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf(object);
if (object === null)
break;
}
return object;
}
function _get() {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get2(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base)
return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(arguments.length < 3 ? target : receiver);
}
return desc.value;
};
}
return _get.apply(this, arguments);
}
var defaults = {
/**
* Type of the movement.
*
* Available types:
* `slider` - Rewinds slider to the start/end when it reaches the first or last slide.
* `carousel` - Changes slides without starting over when it reaches the first or last slide.
*
* @type {String}
*/
type: "slider",
/**
* Start at specific slide number defined with zero-based index.
*
* @type {Number}
*/
startAt: 0,
/**
* A number of slides visible on the single viewport.
*
* @type {Number}
*/
perView: 1,
/**
* Focus currently active slide at a specified position in the track.
*
* Available inputs:
* `center` - Current slide will be always focused at the center of a track.
* `0,1,2,3...` - Current slide will be focused on the specified zero-based index.
*
* @type {String|Number}
*/
focusAt: 0,
/**
* A size of the gap added between slides.
*
* @type {Number}
*/
gap: 10,
/**
* Change slides after a specified interval. Use `false` for turning off autoplay.
*
* @type {Number|Boolean}
*/
autoplay: false,
/**
* Stop autoplay on mouseover event.
*
* @type {Boolean}
*/
hoverpause: true,
/**
* Allow for changing slides with left and right keyboard arrows.
*
* @type {Boolean}
*/
keyboard: true,
/**
* Stop running `perView` number of slides from the end. Use this
* option if you don't want to have an empty space after
* a slider. Works only with `slider` type and a
* non-centered `focusAt` setting.
*
* @type {Boolean}
*/
bound: false,
/**
* Minimal swipe distance needed to change the slide. Use `false` for turning off a swiping.
*
* @type {Number|Boolean}
*/
swipeThreshold: 80,
/**
* Minimal mouse drag distance needed to change the slide. Use `false` for turning off a dragging.
*
* @type {Number|Boolean}
*/
dragThreshold: 120,
/**
* A number of slides moved on single swipe.
*
* Available types:
* `` - Moves slider by one slide per swipe
* `|` - Moves slider between views per swipe (number of slides defined in `perView` options)
*
* @type {String}
*/
perSwipe: "",
/**
* Moving distance ratio of the slides on a swiping and dragging.
*
* @type {Number}
*/
touchRatio: 0.5,
/**
* Angle required to activate slides moving on swiping or dragging.
*
* @type {Number}
*/
touchAngle: 45,
/**
* Duration of the animation in milliseconds.
*
* @type {Number}
*/
animationDuration: 400,
/**
* Allows looping the `slider` type. Slider will rewind to the first/last slide when it's at the start/end.
*
* @type {Boolean}
*/
rewind: true,
/**
* Duration of the rewinding animation of the `slider` type in milliseconds.
*
* @type {Number}
*/
rewindDuration: 800,
/**
* Easing function for the animation.
*
* @type {String}
*/
animationTimingFunc: "cubic-bezier(.165, .840, .440, 1)",
/**
* Wait for the animation to finish until the next user input can be processed
*
* @type {boolean}
*/
waitForTransition: true,
/**
* Throttle costly events at most once per every wait milliseconds.
*
* @type {Number}
*/
throttle: 10,
/**
* Moving direction mode.
*
* Available inputs:
* - 'ltr' - left to right movement,
* - 'rtl' - right to left movement.
*
* @type {String}
*/
direction: "ltr",
/**
* The distance value of the next and previous viewports which
* have to peek in the current view. Accepts number and
* pixels as a string. Left and right peeking can be
* set up separately with a directions object.
*
* For example:
* `100` - Peek 100px on the both sides.
* { before: 100, after: 50 }` - Peek 100px on the left side and 50px on the right side.
*
* @type {Number|String|Object}
*/
peek: 0,
/**
* Defines how many clones of current viewport will be generated.
*
* @type {Number}
*/
cloningRatio: 1,
/**
* Collection of options applied at specified media breakpoints.
* For example: display two slides per view under 800px.
* `{
* '800px': {
* perView: 2
* }
* }`
*/
breakpoints: {},
/**
* Collection of internally used HTML classes.
*
* @todo Refactor `slider` and `carousel` properties to single `type: { slider: '', carousel: '' }` object
* @type {Object}
*/
classes: {
swipeable: "glide--swipeable",
dragging: "glide--dragging",
direction: {
ltr: "glide--ltr",
rtl: "glide--rtl"
},
type: {
slider: "glide--slider",
carousel: "glide--carousel"
},
slide: {
clone: "glide__slide--clone",
active: "glide__slide--active"
},
arrow: {
disabled: "glide__arrow--disabled"
},
nav: {
active: "glide__bullet--active"
}
}
};
function warn(msg) {
console.error("[Glide warn]: ".concat(msg));
}
function toInt(value) {
return parseInt(value);
}
function toFloat(value) {
return parseFloat(value);
}
function isString(value) {
return typeof value === "string";
}
function isObject(value) {
var type = _typeof(value);
return type === "function" || type === "object" && !!value;
}
function isFunction(value) {
return typeof value === "function";
}
function isUndefined(value) {
return typeof value === "undefined";
}
function isArray(value) {
return value.constructor === Array;
}
function mount(glide, extensions, events) {
var components = {};
for (var name in extensions) {
if (isFunction(extensions[name])) {
components[name] = extensions[name](glide, components, events);
} else {
warn("Extension must be a function");
}
}
for (var _name in components) {
if (isFunction(components[_name].mount)) {
components[_name].mount();
}
}
return components;
}
function define(obj, prop, definition) {
Object.defineProperty(obj, prop, definition);
}
function sortKeys(obj) {
return Object.keys(obj).sort().reduce(function(r, k) {
r[k] = obj[k];
return r[k], r;
}, {});
}
function mergeOptions(defaults2, settings) {
var options2 = Object.assign({}, defaults2, settings);
if (settings.hasOwnProperty("classes")) {
options2.classes = Object.assign({}, defaults2.classes, settings.classes);
if (settings.classes.hasOwnProperty("direction")) {
options2.classes.direction = Object.assign({}, defaults2.classes.direction, settings.classes.direction);
}
if (settings.classes.hasOwnProperty("type")) {
options2.classes.type = Object.assign({}, defaults2.classes.type, settings.classes.type);
}
if (settings.classes.hasOwnProperty("slide")) {
options2.classes.slide = Object.assign({}, defaults2.classes.slide, settings.classes.slide);
}
if (settings.classes.hasOwnProperty("arrow")) {
options2.classes.arrow = Object.assign({}, defaults2.classes.arrow, settings.classes.arrow);
}
if (settings.classes.hasOwnProperty("nav")) {
options2.classes.nav = Object.assign({}, defaults2.classes.nav, settings.classes.nav);
}
}
if (settings.hasOwnProperty("breakpoints")) {
options2.breakpoints = Object.assign({}, defaults2.breakpoints, settings.breakpoints);
}
return options2;
}
var EventsBus = /* @__PURE__ */ function() {
function EventsBus2() {
var events = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
_classCallCheck(this, EventsBus2);
this.events = events;
this.hop = events.hasOwnProperty;
}
_createClass(EventsBus2, [{
key: "on",
value: function on(event, handler) {
if (isArray(event)) {
for (var i = 0; i < event.length; i++) {
this.on(event[i], handler);
}
return;
}
if (!this.hop.call(this.events, event)) {
this.events[event] = [];
}
var index = this.events[event].push(handler) - 1;
return {
remove: function remove() {
delete this.events[event][index];
}
};
}
/**
* Runs registered handlers for specified event.
*
* @param {String|Array} event
* @param {Object=} context
*/
}, {
key: "emit",
value: function emit(event, context) {
if (isArray(event)) {
for (var i = 0; i < event.length; i++) {
this.emit(event[i], context);
}
return;
}
if (!this.hop.call(this.events, event)) {
return;
}
this.events[event].forEach(function(item) {
item(context || {});
});
}
}]);
return EventsBus2;
}();
var Glide$1 = /* @__PURE__ */ function() {
function Glide2(selector) {
var options2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
_classCallCheck(this, Glide2);
this._c = {};
this._t = [];
this._e = new EventsBus();
this.disabled = false;
this.selector = selector;
this.settings = mergeOptions(defaults, options2);
this.index = this.settings.startAt;
}
_createClass(Glide2, [{
key: "mount",
value: function mount$1() {
var extensions = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
this._e.emit("mount.before");
if (isObject(extensions)) {
this._c = mount(this, extensions, this._e);
} else {
warn("You need to provide a object on `mount()`");
}
this._e.emit("mount.after");
return this;
}
/**
* Collects an instance `translate` transformers.
*
* @param {Array} transformers Collection of transformers.
* @return {Void}
*/
}, {
key: "mutate",
value: function mutate() {
var transformers = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
if (isArray(transformers)) {
this._t = transformers;
} else {
warn("You need to provide a array on `mutate()`");
}
return this;
}
/**
* Updates glide with specified settings.
*
* @param {Object} settings
* @return {Glide}
*/
}, {
key: "update",
value: function update() {
var settings = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
this.settings = mergeOptions(this.settings, settings);
if (settings.hasOwnProperty("startAt")) {
this.index = settings.startAt;
}
this._e.emit("update");
return this;
}
/**
* Change slide with specified pattern. A pattern must be in the special format:
* `>` - Move one forward
* `<` - Move one backward
* `={i}` - Go to {i} zero-based slide (eq. '=1', will go to second slide)
* `>>` - Rewinds to end (last slide)
* `<<` - Rewinds to start (first slide)
* `|>` - Move one viewport forward
* `|<` - Move one viewport backward
*
* @param {String} pattern
* @return {Glide}
*/
}, {
key: "go",
value: function go(pattern) {
this._c.Run.make(pattern);
return this;
}
/**
* Move track by specified distance.
*
* @param {String} distance
* @return {Glide}
*/
}, {
key: "move",
value: function move(distance) {
this._c.Transition.disable();
this._c.Move.make(distance);
return this;
}
/**
* Destroy instance and revert all changes done by this._c.
*
* @return {Glide}
*/
}, {
key: "destroy",
value: function destroy() {
this._e.emit("destroy");
return this;
}
/**
* Start instance autoplaying.
*
* @param {Boolean|Number} interval Run autoplaying with passed interval regardless of `autoplay` settings
* @return {Glide}
*/
}, {
key: "play",
value: function play() {
var interval = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
if (interval) {
this.settings.autoplay = interval;
}
this._e.emit("play");
return this;
}
/**
* Stop instance autoplaying.
*
* @return {Glide}
*/
}, {
key: "pause",
value: function pause() {
this._e.emit("pause");
return this;
}
/**
* Sets glide into a idle status.
*
* @return {Glide}
*/
}, {
key: "disable",
value: function disable() {
this.disabled = true;
return this;
}
/**
* Sets glide into a active status.
*
* @return {Glide}
*/
}, {
key: "enable",
value: function enable() {
this.disabled = false;
return this;
}
/**
* Adds cuutom event listener with handler.
*
* @param {String|Array} event
* @param {Function} handler
* @return {Glide}
*/
}, {
key: "on",
value: function on(event, handler) {
this._e.on(event, handler);
return this;
}
/**
* Checks if glide is a precised type.
*
* @param {String} name
* @return {Boolean}
*/
}, {
key: "isType",
value: function isType(name) {
return this.settings.type === name;
}
/**
* Gets value of the core options.
*
* @return {Object}
*/
}, {
key: "settings",
get: function get() {
return this._o;
},
set: function set(o) {
if (isObject(o)) {
this._o = o;
} else {
warn("Options must be an `object` instance.");
}
}
/**
* Gets current index of the slider.
*
* @return {Object}
*/
}, {
key: "index",
get: function get() {
return this._i;
},
set: function set(i) {
this._i = toInt(i);
}
/**
* Gets type name of the slider.
*
* @return {String}
*/
}, {
key: "type",
get: function get() {
return this.settings.type;
}
/**
* Gets value of the idle status.
*
* @return {Boolean}
*/
}, {
key: "disabled",
get: function get() {
return this._d;
},
set: function set(status) {
this._d = !!status;
}
}]);
return Glide2;
}();
function Run(Glide2, Components, Events) {
var Run2 = {
/**
* Initializes autorunning of the glide.
*
* @return {Void}
*/
mount: function mount2() {
this._o = false;
},
/**
* Makes glides running based on the passed moving schema.
*
* @param {String} move
*/
make: function make(move) {
var _this = this;
if (!Glide2.disabled) {
!Glide2.settings.waitForTransition || Glide2.disable();
this.move = move;
Events.emit("run.before", this.move);
this.calculate();
Events.emit("run", this.move);
Components.Transition.after(function() {
if (_this.isStart()) {
Events.emit("run.start", _this.move);
}
if (_this.isEnd()) {
Events.emit("run.end", _this.move);
}
if (_this.isOffset()) {
_this._o = false;
Events.emit("run.offset", _this.move);
}
Events.emit("run.after", _this.move);
Glide2.enable();
});
}
},
/**
* Calculates current index based on defined move.
*
* @return {Number|Undefined}
*/
calculate: function calculate() {
var move = this.move, length = this.length;
var steps = move.steps, direction = move.direction;
var viewSize = 1;
if (direction === "=") {
if (Glide2.settings.bound && toInt(steps) > length) {
Glide2.index = length;
return;
}
Glide2.index = steps;
return;
}
if (direction === ">" && steps === ">") {
Glide2.index = length;
return;
}
if (direction === "<" && steps === "<") {
Glide2.index = 0;
return;
}
if (direction === "|") {
viewSize = Glide2.settings.perView || 1;
}
if (direction === ">" || direction === "|" && steps === ">") {
var index = calculateForwardIndex(viewSize);
if (index > length) {
this._o = true;
}
Glide2.index = normalizeForwardIndex(index, viewSize);
return;
}
if (direction === "<" || direction === "|" && steps === "<") {
var _index = calculateBackwardIndex(viewSize);
if (_index < 0) {
this._o = true;
}
Glide2.index = normalizeBackwardIndex(_index, viewSize);
return;
}
warn("Invalid direction pattern [".concat(direction).concat(steps, "] has been used"));
},
/**
* Checks if we are on the first slide.
*
* @return {Boolean}
*/
isStart: function isStart() {
return Glide2.index <= 0;
},
/**
* Checks if we are on the last slide.
*
* @return {Boolean}
*/
isEnd: function isEnd() {
return Glide2.index >= this.length;
},
/**
* Checks if we are making a offset run.
*
* @param {String} direction
* @return {Boolean}
*/
isOffset: function isOffset() {
var direction = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : void 0;
if (!direction) {
return this._o;
}
if (!this._o) {
return false;
}
if (direction === "|>") {
return this.move.direction === "|" && this.move.steps === ">";
}
if (direction === "|<") {
return this.move.direction === "|" && this.move.steps === "<";
}
return this.move.direction === direction;
},
/**
* Checks if bound mode is active
*
* @return {Boolean}
*/
isBound: function isBound() {
return Glide2.isType("slider") && Glide2.settings.focusAt !== "center" && Glide2.settings.bound;
}
};
function calculateForwardIndex(viewSize) {
var index = Glide2.index;
if (Glide2.isType("carousel")) {
return index + viewSize;
}
return index + (viewSize - index % viewSize);
}
function normalizeForwardIndex(index, viewSize) {
var length = Run2.length;
if (index <= length) {
return index;
}
if (Glide2.isType("carousel")) {
return index - (length + 1);
}
if (Glide2.settings.rewind) {
if (Run2.isBound() && !Run2.isEnd()) {
return length;
}
return 0;
}
if (Run2.isBound()) {
return length;
}
return Math.floor(length / viewSize) * viewSize;
}
function calculateBackwardIndex(viewSize) {
var index = Glide2.index;
if (Glide2.isType("carousel")) {
return index - viewSize;
}
var view = Math.ceil(index / viewSize);
return (view - 1) * viewSize;
}
function normalizeBackwardIndex(index, viewSize) {
var length = Run2.length;
if (index >= 0) {
return index;
}
if (Glide2.isType("carousel")) {
return index + (length + 1);
}
if (Glide2.settings.rewind) {
if (Run2.isBound() && Run2.isStart()) {
return length;
}
return Math.floor(length / viewSize) * viewSize;
}
return 0;
}
define(Run2, "move", {
/**
* Gets value of the move schema.
*
* @returns {Object}
*/
get: function get() {
return this._m;
},
/**
* Sets value of the move schema.
*
* @returns {Object}
*/
set: function set(value) {
var step = value.substr(1);
this._m = {
direction: value.substr(0, 1),
steps: step ? toInt(step) ? toInt(step) : step : 0
};
}
});
define(Run2, "length", {
/**
* Gets value of the running distance based
* on zero-indexing number of slides.
*
* @return {Number}
*/
get: function get() {
var settings = Glide2.settings;
var length = Components.Html.slides.length;
if (this.isBound()) {
return length - 1 - (toInt(settings.perView) - 1) + toInt(settings.focusAt);
}
return length - 1;
}
});
define(Run2, "offset", {
/**
* Gets status of the offsetting flag.
*
* @return {Boolean}
*/
get: function get() {
return this._o;
}
});
return Run2;
}
function now() {
return (/* @__PURE__ */ new Date()).getTime();
}
function throttle(func, wait, options2) {
var timeout, context, args, result;
var previous = 0;
if (!options2)
options2 = {};
var later = function later2() {
previous = options2.leading === false ? 0 : now();
timeout = null;
result = func.apply(context, args);
if (!timeout)
context = args = null;
};
var throttled = function throttled2() {
var at = now();
if (!previous && options2.leading === false)
previous = at;
var remaining = wait - (at - previous);
context = this;
args = arguments;
if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
previous = at;
result = func.apply(context, args);
if (!timeout)
context = args = null;
} else if (!timeout && options2.trailing !== false) {
timeout = setTimeout(later, remaining);
}
return result;
};
throttled.cancel = function() {
clearTimeout(timeout);
previous = 0;
timeout = context = args = null;
};
return throttled;
}
var MARGIN_TYPE = {
ltr: ["marginLeft", "marginRight"],
rtl: ["marginRight", "marginLeft"]
};
function Gaps(Glide2, Components, Events) {
var Gaps2 = {
/**
* Applies gaps between slides. First and last
* slides do not receive it's edge margins.
*
* @param {HTMLCollection} slides
* @return {Void}
*/
apply: function apply(slides) {
for (var i = 0, len = slides.length; i < len; i++) {
var style = slides[i].style;
var direction = Components.Direction.value;
if (i !== 0) {
style[MARGIN_TYPE[direction][0]] = "".concat(this.value / 2, "px");
} else {
style[MARGIN_TYPE[direction][0]] = "";
}
if (i !== slides.length - 1) {
style[MARGIN_TYPE[direction][1]] = "".concat(this.value / 2, "px");
} else {
style[MARGIN_TYPE[direction][1]] = "";
}
}
},
/**
* Removes gaps from the slides.
*