Browse code

Refactor and rewrite as contao bundle

Benjamin Roth authored on04/11/2022 22:32:32
Showing1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,89 +0,0 @@
1
-"use strict";
2
-
3
-exports.__esModule = true;
4
-exports.calcLoopedSlides = calcLoopedSlides;
5
-exports.renderLoop = renderLoop;
6
-
7
-var _vue = require("vue");
8
-
9
-var _core = _interopRequireDefault(require("../../core"));
10
-
11
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
-function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
-
15
-function calcLoopedSlides(slides, swiperParams) {
16
-  var slidesPerViewParams = swiperParams.slidesPerView;
17
-
18
-  if (swiperParams.breakpoints) {
19
-    var breakpoint = _core.default.prototype.getBreakpoint(swiperParams.breakpoints);
20
-
21
-    var breakpointOnlyParams = breakpoint in swiperParams.breakpoints ? swiperParams.breakpoints[breakpoint] : undefined;
22
-
23
-    if (breakpointOnlyParams && breakpointOnlyParams.slidesPerView) {
24
-      slidesPerViewParams = breakpointOnlyParams.slidesPerView;
25
-    }
26
-  }
27
-
28
-  var loopedSlides = Math.ceil(parseFloat(swiperParams.loopedSlides || slidesPerViewParams, 10));
29
-  loopedSlides += swiperParams.loopAdditionalSlides;
30
-
31
-  if (loopedSlides > slides.length) {
32
-    loopedSlides = slides.length;
33
-  }
34
-
35
-  return loopedSlides;
36
-}
37
-
38
-function renderLoop(swiperRef, slides, swiperParams) {
39
-  var modifiedSlides = slides.map(function (child, index) {
40
-    if (!child.props) child.props = {};
41
-    child.props.swiperRef = swiperRef;
42
-    child.props['data-swiper-slide-index'] = index;
43
-    return child;
44
-  });
45
-
46
-  function duplicateSlide(child, index, position) {
47
-    if (!child.props) child.props = {};
48
-    return (0, _vue.h)(child.type, _extends({}, child.props, {
49
-      key: child.key + "-duplicate-" + index + "-" + position,
50
-      class: (child.props.className || '') + " " + swiperParams.slideDuplicateClass + " " + (child.props.class || '')
51
-    }), child.children);
52
-  }
53
-
54
-  if (swiperParams.loopFillGroupWithBlank) {
55
-    var blankSlidesNum = swiperParams.slidesPerGroup - modifiedSlides.length % swiperParams.slidesPerGroup;
56
-
57
-    if (blankSlidesNum !== swiperParams.slidesPerGroup) {
58
-      for (var i = 0; i < blankSlidesNum; i += 1) {
59
-        var blankSlide = (0, _vue.h)('div', {
60
-          class: swiperParams.slideClass + " " + swiperParams.slideBlankClass
61
-        });
62
-        modifiedSlides.push(blankSlide);
63
-      }
64
-    }
65
-  }
66
-
67
-  if (swiperParams.slidesPerView === 'auto' && !swiperParams.loopedSlides) {
68
-    swiperParams.loopedSlides = modifiedSlides.length;
69
-  }
70
-
71
-  var loopedSlides = calcLoopedSlides(modifiedSlides, swiperParams);
72
-  var prependSlides = [];
73
-  var appendSlides = [];
74
-  modifiedSlides.forEach(function (child, index) {
75
-    if (index < loopedSlides) {
76
-      appendSlides.push(duplicateSlide(child, index, 'prepend'));
77
-    }
78
-
79
-    if (index < modifiedSlides.length && index >= modifiedSlides.length - loopedSlides) {
80
-      prependSlides.push(duplicateSlide(child, index, 'append'));
81
-    }
82
-  });
83
-
84
-  if (swiperRef.value) {
85
-    swiperRef.value.loopedSlides = loopedSlides;
86
-  }
87
-
88
-  return [].concat(prependSlides, modifiedSlides, appendSlides);
89
-}
90 0
\ No newline at end of file
Browse code

swiper.js version 6.5.0

Benjamin Roth authored on14/03/2021 15:29:46
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,89 @@
1
+"use strict";
2
+
3
+exports.__esModule = true;
4
+exports.calcLoopedSlides = calcLoopedSlides;
5
+exports.renderLoop = renderLoop;
6
+
7
+var _vue = require("vue");
8
+
9
+var _core = _interopRequireDefault(require("../../core"));
10
+
11
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
+
15
+function calcLoopedSlides(slides, swiperParams) {
16
+  var slidesPerViewParams = swiperParams.slidesPerView;
17
+
18
+  if (swiperParams.breakpoints) {
19
+    var breakpoint = _core.default.prototype.getBreakpoint(swiperParams.breakpoints);
20
+
21
+    var breakpointOnlyParams = breakpoint in swiperParams.breakpoints ? swiperParams.breakpoints[breakpoint] : undefined;
22
+
23
+    if (breakpointOnlyParams && breakpointOnlyParams.slidesPerView) {
24
+      slidesPerViewParams = breakpointOnlyParams.slidesPerView;
25
+    }
26
+  }
27
+
28
+  var loopedSlides = Math.ceil(parseFloat(swiperParams.loopedSlides || slidesPerViewParams, 10));
29
+  loopedSlides += swiperParams.loopAdditionalSlides;
30
+
31
+  if (loopedSlides > slides.length) {
32
+    loopedSlides = slides.length;
33
+  }
34
+
35
+  return loopedSlides;
36
+}
37
+
38
+function renderLoop(swiperRef, slides, swiperParams) {
39
+  var modifiedSlides = slides.map(function (child, index) {
40
+    if (!child.props) child.props = {};
41
+    child.props.swiperRef = swiperRef;
42
+    child.props['data-swiper-slide-index'] = index;
43
+    return child;
44
+  });
45
+
46
+  function duplicateSlide(child, index, position) {
47
+    if (!child.props) child.props = {};
48
+    return (0, _vue.h)(child.type, _extends({}, child.props, {
49
+      key: child.key + "-duplicate-" + index + "-" + position,
50
+      class: (child.props.className || '') + " " + swiperParams.slideDuplicateClass + " " + (child.props.class || '')
51
+    }), child.children);
52
+  }
53
+
54
+  if (swiperParams.loopFillGroupWithBlank) {
55
+    var blankSlidesNum = swiperParams.slidesPerGroup - modifiedSlides.length % swiperParams.slidesPerGroup;
56
+
57
+    if (blankSlidesNum !== swiperParams.slidesPerGroup) {
58
+      for (var i = 0; i < blankSlidesNum; i += 1) {
59
+        var blankSlide = (0, _vue.h)('div', {
60
+          class: swiperParams.slideClass + " " + swiperParams.slideBlankClass
61
+        });
62
+        modifiedSlides.push(blankSlide);
63
+      }
64
+    }
65
+  }
66
+
67
+  if (swiperParams.slidesPerView === 'auto' && !swiperParams.loopedSlides) {
68
+    swiperParams.loopedSlides = modifiedSlides.length;
69
+  }
70
+
71
+  var loopedSlides = calcLoopedSlides(modifiedSlides, swiperParams);
72
+  var prependSlides = [];
73
+  var appendSlides = [];
74
+  modifiedSlides.forEach(function (child, index) {
75
+    if (index < loopedSlides) {
76
+      appendSlides.push(duplicateSlide(child, index, 'prepend'));
77
+    }
78
+
79
+    if (index < modifiedSlides.length && index >= modifiedSlides.length - loopedSlides) {
80
+      prependSlides.push(duplicateSlide(child, index, 'append'));
81
+    }
82
+  });
83
+
84
+  if (swiperRef.value) {
85
+    swiperRef.value.loopedSlides = loopedSlides;
86
+  }
87
+
88
+  return [].concat(prependSlides, modifiedSlides, appendSlides);
89
+}
0 90
\ No newline at end of file