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,187 +0,0 @@
1
-"use strict";
2
-
3
-exports.__esModule = true;
4
-exports.default = void 0;
5
-
6
-var _ssrWindow = require("ssr-window");
7
-
8
-var _utils = require("../../utils/utils");
9
-
10
-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); }
11
-
12
-var Autoplay = {
13
-  run: function run() {
14
-    var swiper = this;
15
-    var $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
16
-    var delay = swiper.params.autoplay.delay;
17
-
18
-    if ($activeSlideEl.attr('data-swiper-autoplay')) {
19
-      delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
20
-    }
21
-
22
-    clearTimeout(swiper.autoplay.timeout);
23
-    swiper.autoplay.timeout = (0, _utils.nextTick)(function () {
24
-      var autoplayResult;
25
-
26
-      if (swiper.params.autoplay.reverseDirection) {
27
-        if (swiper.params.loop) {
28
-          swiper.loopFix();
29
-          autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
30
-          swiper.emit('autoplay');
31
-        } else if (!swiper.isBeginning) {
32
-          autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
33
-          swiper.emit('autoplay');
34
-        } else if (!swiper.params.autoplay.stopOnLastSlide) {
35
-          autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
36
-          swiper.emit('autoplay');
37
-        } else {
38
-          swiper.autoplay.stop();
39
-        }
40
-      } else if (swiper.params.loop) {
41
-        swiper.loopFix();
42
-        autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
43
-        swiper.emit('autoplay');
44
-      } else if (!swiper.isEnd) {
45
-        autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
46
-        swiper.emit('autoplay');
47
-      } else if (!swiper.params.autoplay.stopOnLastSlide) {
48
-        autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true);
49
-        swiper.emit('autoplay');
50
-      } else {
51
-        swiper.autoplay.stop();
52
-      }
53
-
54
-      if (swiper.params.cssMode && swiper.autoplay.running) swiper.autoplay.run();else if (autoplayResult === false) {
55
-        swiper.autoplay.run();
56
-      }
57
-    }, delay);
58
-  },
59
-  start: function start() {
60
-    var swiper = this;
61
-    if (typeof swiper.autoplay.timeout !== 'undefined') return false;
62
-    if (swiper.autoplay.running) return false;
63
-    swiper.autoplay.running = true;
64
-    swiper.emit('autoplayStart');
65
-    swiper.autoplay.run();
66
-    return true;
67
-  },
68
-  stop: function stop() {
69
-    var swiper = this;
70
-    if (!swiper.autoplay.running) return false;
71
-    if (typeof swiper.autoplay.timeout === 'undefined') return false;
72
-
73
-    if (swiper.autoplay.timeout) {
74
-      clearTimeout(swiper.autoplay.timeout);
75
-      swiper.autoplay.timeout = undefined;
76
-    }
77
-
78
-    swiper.autoplay.running = false;
79
-    swiper.emit('autoplayStop');
80
-    return true;
81
-  },
82
-  pause: function pause(speed) {
83
-    var swiper = this;
84
-    if (!swiper.autoplay.running) return;
85
-    if (swiper.autoplay.paused) return;
86
-    if (swiper.autoplay.timeout) clearTimeout(swiper.autoplay.timeout);
87
-    swiper.autoplay.paused = true;
88
-
89
-    if (speed === 0 || !swiper.params.autoplay.waitForTransition) {
90
-      swiper.autoplay.paused = false;
91
-      swiper.autoplay.run();
92
-    } else {
93
-      swiper.$wrapperEl[0].addEventListener('transitionend', swiper.autoplay.onTransitionEnd);
94
-      swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd);
95
-    }
96
-  },
97
-  onVisibilityChange: function onVisibilityChange() {
98
-    var swiper = this;
99
-    var document = (0, _ssrWindow.getDocument)();
100
-
101
-    if (document.visibilityState === 'hidden' && swiper.autoplay.running) {
102
-      swiper.autoplay.pause();
103
-    }
104
-
105
-    if (document.visibilityState === 'visible' && swiper.autoplay.paused) {
106
-      swiper.autoplay.run();
107
-      swiper.autoplay.paused = false;
108
-    }
109
-  },
110
-  onTransitionEnd: function onTransitionEnd(e) {
111
-    var swiper = this;
112
-    if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return;
113
-    if (e.target !== swiper.$wrapperEl[0]) return;
114
-    swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.autoplay.onTransitionEnd);
115
-    swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd);
116
-    swiper.autoplay.paused = false;
117
-
118
-    if (!swiper.autoplay.running) {
119
-      swiper.autoplay.stop();
120
-    } else {
121
-      swiper.autoplay.run();
122
-    }
123
-  }
124
-};
125
-var _default = {
126
-  name: 'autoplay',
127
-  params: {
128
-    autoplay: {
129
-      enabled: false,
130
-      delay: 3000,
131
-      waitForTransition: true,
132
-      disableOnInteraction: true,
133
-      stopOnLastSlide: false,
134
-      reverseDirection: false
135
-    }
136
-  },
137
-  create: function create() {
138
-    var swiper = this;
139
-    (0, _utils.bindModuleMethods)(swiper, {
140
-      autoplay: _extends({}, Autoplay, {
141
-        running: false,
142
-        paused: false
143
-      })
144
-    });
145
-  },
146
-  on: {
147
-    init: function init(swiper) {
148
-      if (swiper.params.autoplay.enabled) {
149
-        swiper.autoplay.start();
150
-        var document = (0, _ssrWindow.getDocument)();
151
-        document.addEventListener('visibilitychange', swiper.autoplay.onVisibilityChange);
152
-      }
153
-    },
154
-    beforeTransitionStart: function beforeTransitionStart(swiper, speed, internal) {
155
-      if (swiper.autoplay.running) {
156
-        if (internal || !swiper.params.autoplay.disableOnInteraction) {
157
-          swiper.autoplay.pause(speed);
158
-        } else {
159
-          swiper.autoplay.stop();
160
-        }
161
-      }
162
-    },
163
-    sliderFirstMove: function sliderFirstMove(swiper) {
164
-      if (swiper.autoplay.running) {
165
-        if (swiper.params.autoplay.disableOnInteraction) {
166
-          swiper.autoplay.stop();
167
-        } else {
168
-          swiper.autoplay.pause();
169
-        }
170
-      }
171
-    },
172
-    touchEnd: function touchEnd(swiper) {
173
-      if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) {
174
-        swiper.autoplay.run();
175
-      }
176
-    },
177
-    destroy: function destroy(swiper) {
178
-      if (swiper.autoplay.running) {
179
-        swiper.autoplay.stop();
180
-      }
181
-
182
-      var document = (0, _ssrWindow.getDocument)();
183
-      document.removeEventListener('visibilitychange', swiper.autoplay.onVisibilityChange);
184
-    }
185
-  }
186
-};
187
-exports.default = _default;
188 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,187 @@
1
+"use strict";
2
+
3
+exports.__esModule = true;
4
+exports.default = void 0;
5
+
6
+var _ssrWindow = require("ssr-window");
7
+
8
+var _utils = require("../../utils/utils");
9
+
10
+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); }
11
+
12
+var Autoplay = {
13
+  run: function run() {
14
+    var swiper = this;
15
+    var $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
16
+    var delay = swiper.params.autoplay.delay;
17
+
18
+    if ($activeSlideEl.attr('data-swiper-autoplay')) {
19
+      delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
20
+    }
21
+
22
+    clearTimeout(swiper.autoplay.timeout);
23
+    swiper.autoplay.timeout = (0, _utils.nextTick)(function () {
24
+      var autoplayResult;
25
+
26
+      if (swiper.params.autoplay.reverseDirection) {
27
+        if (swiper.params.loop) {
28
+          swiper.loopFix();
29
+          autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
30
+          swiper.emit('autoplay');
31
+        } else if (!swiper.isBeginning) {
32
+          autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
33
+          swiper.emit('autoplay');
34
+        } else if (!swiper.params.autoplay.stopOnLastSlide) {
35
+          autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
36
+          swiper.emit('autoplay');
37
+        } else {
38
+          swiper.autoplay.stop();
39
+        }
40
+      } else if (swiper.params.loop) {
41
+        swiper.loopFix();
42
+        autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
43
+        swiper.emit('autoplay');
44
+      } else if (!swiper.isEnd) {
45
+        autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
46
+        swiper.emit('autoplay');
47
+      } else if (!swiper.params.autoplay.stopOnLastSlide) {
48
+        autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true);
49
+        swiper.emit('autoplay');
50
+      } else {
51
+        swiper.autoplay.stop();
52
+      }
53
+
54
+      if (swiper.params.cssMode && swiper.autoplay.running) swiper.autoplay.run();else if (autoplayResult === false) {
55
+        swiper.autoplay.run();
56
+      }
57
+    }, delay);
58
+  },
59
+  start: function start() {
60
+    var swiper = this;
61
+    if (typeof swiper.autoplay.timeout !== 'undefined') return false;
62
+    if (swiper.autoplay.running) return false;
63
+    swiper.autoplay.running = true;
64
+    swiper.emit('autoplayStart');
65
+    swiper.autoplay.run();
66
+    return true;
67
+  },
68
+  stop: function stop() {
69
+    var swiper = this;
70
+    if (!swiper.autoplay.running) return false;
71
+    if (typeof swiper.autoplay.timeout === 'undefined') return false;
72
+
73
+    if (swiper.autoplay.timeout) {
74
+      clearTimeout(swiper.autoplay.timeout);
75
+      swiper.autoplay.timeout = undefined;
76
+    }
77
+
78
+    swiper.autoplay.running = false;
79
+    swiper.emit('autoplayStop');
80
+    return true;
81
+  },
82
+  pause: function pause(speed) {
83
+    var swiper = this;
84
+    if (!swiper.autoplay.running) return;
85
+    if (swiper.autoplay.paused) return;
86
+    if (swiper.autoplay.timeout) clearTimeout(swiper.autoplay.timeout);
87
+    swiper.autoplay.paused = true;
88
+
89
+    if (speed === 0 || !swiper.params.autoplay.waitForTransition) {
90
+      swiper.autoplay.paused = false;
91
+      swiper.autoplay.run();
92
+    } else {
93
+      swiper.$wrapperEl[0].addEventListener('transitionend', swiper.autoplay.onTransitionEnd);
94
+      swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd);
95
+    }
96
+  },
97
+  onVisibilityChange: function onVisibilityChange() {
98
+    var swiper = this;
99
+    var document = (0, _ssrWindow.getDocument)();
100
+
101
+    if (document.visibilityState === 'hidden' && swiper.autoplay.running) {
102
+      swiper.autoplay.pause();
103
+    }
104
+
105
+    if (document.visibilityState === 'visible' && swiper.autoplay.paused) {
106
+      swiper.autoplay.run();
107
+      swiper.autoplay.paused = false;
108
+    }
109
+  },
110
+  onTransitionEnd: function onTransitionEnd(e) {
111
+    var swiper = this;
112
+    if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return;
113
+    if (e.target !== swiper.$wrapperEl[0]) return;
114
+    swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.autoplay.onTransitionEnd);
115
+    swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd);
116
+    swiper.autoplay.paused = false;
117
+
118
+    if (!swiper.autoplay.running) {
119
+      swiper.autoplay.stop();
120
+    } else {
121
+      swiper.autoplay.run();
122
+    }
123
+  }
124
+};
125
+var _default = {
126
+  name: 'autoplay',
127
+  params: {
128
+    autoplay: {
129
+      enabled: false,
130
+      delay: 3000,
131
+      waitForTransition: true,
132
+      disableOnInteraction: true,
133
+      stopOnLastSlide: false,
134
+      reverseDirection: false
135
+    }
136
+  },
137
+  create: function create() {
138
+    var swiper = this;
139
+    (0, _utils.bindModuleMethods)(swiper, {
140
+      autoplay: _extends({}, Autoplay, {
141
+        running: false,
142
+        paused: false
143
+      })
144
+    });
145
+  },
146
+  on: {
147
+    init: function init(swiper) {
148
+      if (swiper.params.autoplay.enabled) {
149
+        swiper.autoplay.start();
150
+        var document = (0, _ssrWindow.getDocument)();
151
+        document.addEventListener('visibilitychange', swiper.autoplay.onVisibilityChange);
152
+      }
153
+    },
154
+    beforeTransitionStart: function beforeTransitionStart(swiper, speed, internal) {
155
+      if (swiper.autoplay.running) {
156
+        if (internal || !swiper.params.autoplay.disableOnInteraction) {
157
+          swiper.autoplay.pause(speed);
158
+        } else {
159
+          swiper.autoplay.stop();
160
+        }
161
+      }
162
+    },
163
+    sliderFirstMove: function sliderFirstMove(swiper) {
164
+      if (swiper.autoplay.running) {
165
+        if (swiper.params.autoplay.disableOnInteraction) {
166
+          swiper.autoplay.stop();
167
+        } else {
168
+          swiper.autoplay.pause();
169
+        }
170
+      }
171
+    },
172
+    touchEnd: function touchEnd(swiper) {
173
+      if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) {
174
+        swiper.autoplay.run();
175
+      }
176
+    },
177
+    destroy: function destroy(swiper) {
178
+      if (swiper.autoplay.running) {
179
+        swiper.autoplay.stop();
180
+      }
181
+
182
+      var document = (0, _ssrWindow.getDocument)();
183
+      document.removeEventListener('visibilitychange', swiper.autoplay.onVisibilityChange);
184
+    }
185
+  }
186
+};
187
+exports.default = _default;
0 188
\ No newline at end of file