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,82 +0,0 @@
1
-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); }
2
-
3
-import { h } from 'vue'; // eslint-disable-next-line
4
-
5
-import Swiper from '../../core';
6
-
7
-function calcLoopedSlides(slides, swiperParams) {
8
-  var slidesPerViewParams = swiperParams.slidesPerView;
9
-
10
-  if (swiperParams.breakpoints) {
11
-    var breakpoint = Swiper.prototype.getBreakpoint(swiperParams.breakpoints);
12
-    var breakpointOnlyParams = breakpoint in swiperParams.breakpoints ? swiperParams.breakpoints[breakpoint] : undefined;
13
-
14
-    if (breakpointOnlyParams && breakpointOnlyParams.slidesPerView) {
15
-      slidesPerViewParams = breakpointOnlyParams.slidesPerView;
16
-    }
17
-  }
18
-
19
-  var loopedSlides = Math.ceil(parseFloat(swiperParams.loopedSlides || slidesPerViewParams, 10));
20
-  loopedSlides += swiperParams.loopAdditionalSlides;
21
-
22
-  if (loopedSlides > slides.length) {
23
-    loopedSlides = slides.length;
24
-  }
25
-
26
-  return loopedSlides;
27
-}
28
-
29
-function renderLoop(swiperRef, slides, swiperParams) {
30
-  var modifiedSlides = slides.map(function (child, index) {
31
-    if (!child.props) child.props = {};
32
-    child.props.swiperRef = swiperRef;
33
-    child.props['data-swiper-slide-index'] = index;
34
-    return child;
35
-  });
36
-
37
-  function duplicateSlide(child, index, position) {
38
-    if (!child.props) child.props = {};
39
-    return h(child.type, _extends({}, child.props, {
40
-      key: child.key + "-duplicate-" + index + "-" + position,
41
-      class: (child.props.className || '') + " " + swiperParams.slideDuplicateClass + " " + (child.props.class || '')
42
-    }), child.children);
43
-  }
44
-
45
-  if (swiperParams.loopFillGroupWithBlank) {
46
-    var blankSlidesNum = swiperParams.slidesPerGroup - modifiedSlides.length % swiperParams.slidesPerGroup;
47
-
48
-    if (blankSlidesNum !== swiperParams.slidesPerGroup) {
49
-      for (var i = 0; i < blankSlidesNum; i += 1) {
50
-        var blankSlide = h('div', {
51
-          class: swiperParams.slideClass + " " + swiperParams.slideBlankClass
52
-        });
53
-        modifiedSlides.push(blankSlide);
54
-      }
55
-    }
56
-  }
57
-
58
-  if (swiperParams.slidesPerView === 'auto' && !swiperParams.loopedSlides) {
59
-    swiperParams.loopedSlides = modifiedSlides.length;
60
-  }
61
-
62
-  var loopedSlides = calcLoopedSlides(modifiedSlides, swiperParams);
63
-  var prependSlides = [];
64
-  var appendSlides = [];
65
-  modifiedSlides.forEach(function (child, index) {
66
-    if (index < loopedSlides) {
67
-      appendSlides.push(duplicateSlide(child, index, 'prepend'));
68
-    }
69
-
70
-    if (index < modifiedSlides.length && index >= modifiedSlides.length - loopedSlides) {
71
-      prependSlides.push(duplicateSlide(child, index, 'append'));
72
-    }
73
-  });
74
-
75
-  if (swiperRef.value) {
76
-    swiperRef.value.loopedSlides = loopedSlides;
77
-  }
78
-
79
-  return [].concat(prependSlides, modifiedSlides, appendSlides);
80
-}
81
-
82
-export { calcLoopedSlides, renderLoop };
83 0
\ No newline at end of file
Browse code

swiper.js version 6.4.5

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