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,100 +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 Observer = {
13
-  attach: function attach(target, options) {
14
-    if (options === void 0) {
15
-      options = {};
16
-    }
17
-
18
-    var window = (0, _ssrWindow.getWindow)();
19
-    var swiper = this;
20
-    var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
21
-    var observer = new ObserverFunc(function (mutations) {
22
-      // The observerUpdate event should only be triggered
23
-      // once despite the number of mutations.  Additional
24
-      // triggers are redundant and are very costly
25
-      if (mutations.length === 1) {
26
-        swiper.emit('observerUpdate', mutations[0]);
27
-        return;
28
-      }
29
-
30
-      var observerUpdate = function observerUpdate() {
31
-        swiper.emit('observerUpdate', mutations[0]);
32
-      };
33
-
34
-      if (window.requestAnimationFrame) {
35
-        window.requestAnimationFrame(observerUpdate);
36
-      } else {
37
-        window.setTimeout(observerUpdate, 0);
38
-      }
39
-    });
40
-    observer.observe(target, {
41
-      attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
42
-      childList: typeof options.childList === 'undefined' ? true : options.childList,
43
-      characterData: typeof options.characterData === 'undefined' ? true : options.characterData
44
-    });
45
-    swiper.observer.observers.push(observer);
46
-  },
47
-  init: function init() {
48
-    var swiper = this;
49
-    if (!swiper.support.observer || !swiper.params.observer) return;
50
-
51
-    if (swiper.params.observeParents) {
52
-      var containerParents = swiper.$el.parents();
53
-
54
-      for (var i = 0; i < containerParents.length; i += 1) {
55
-        swiper.observer.attach(containerParents[i]);
56
-      }
57
-    } // Observe container
58
-
59
-
60
-    swiper.observer.attach(swiper.$el[0], {
61
-      childList: swiper.params.observeSlideChildren
62
-    }); // Observe wrapper
63
-
64
-    swiper.observer.attach(swiper.$wrapperEl[0], {
65
-      attributes: false
66
-    });
67
-  },
68
-  destroy: function destroy() {
69
-    var swiper = this;
70
-    swiper.observer.observers.forEach(function (observer) {
71
-      observer.disconnect();
72
-    });
73
-    swiper.observer.observers = [];
74
-  }
75
-};
76
-var _default = {
77
-  name: 'observer',
78
-  params: {
79
-    observer: false,
80
-    observeParents: false,
81
-    observeSlideChildren: false
82
-  },
83
-  create: function create() {
84
-    var swiper = this;
85
-    (0, _utils.bindModuleMethods)(swiper, {
86
-      observer: _extends({}, Observer, {
87
-        observers: []
88
-      })
89
-    });
90
-  },
91
-  on: {
92
-    init: function init(swiper) {
93
-      swiper.observer.init();
94
-    },
95
-    destroy: function destroy(swiper) {
96
-      swiper.observer.destroy();
97
-    }
98
-  }
99
-};
100
-exports.default = _default;
101 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,100 @@
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 Observer = {
13
+  attach: function attach(target, options) {
14
+    if (options === void 0) {
15
+      options = {};
16
+    }
17
+
18
+    var window = (0, _ssrWindow.getWindow)();
19
+    var swiper = this;
20
+    var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
21
+    var observer = new ObserverFunc(function (mutations) {
22
+      // The observerUpdate event should only be triggered
23
+      // once despite the number of mutations.  Additional
24
+      // triggers are redundant and are very costly
25
+      if (mutations.length === 1) {
26
+        swiper.emit('observerUpdate', mutations[0]);
27
+        return;
28
+      }
29
+
30
+      var observerUpdate = function observerUpdate() {
31
+        swiper.emit('observerUpdate', mutations[0]);
32
+      };
33
+
34
+      if (window.requestAnimationFrame) {
35
+        window.requestAnimationFrame(observerUpdate);
36
+      } else {
37
+        window.setTimeout(observerUpdate, 0);
38
+      }
39
+    });
40
+    observer.observe(target, {
41
+      attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
42
+      childList: typeof options.childList === 'undefined' ? true : options.childList,
43
+      characterData: typeof options.characterData === 'undefined' ? true : options.characterData
44
+    });
45
+    swiper.observer.observers.push(observer);
46
+  },
47
+  init: function init() {
48
+    var swiper = this;
49
+    if (!swiper.support.observer || !swiper.params.observer) return;
50
+
51
+    if (swiper.params.observeParents) {
52
+      var containerParents = swiper.$el.parents();
53
+
54
+      for (var i = 0; i < containerParents.length; i += 1) {
55
+        swiper.observer.attach(containerParents[i]);
56
+      }
57
+    } // Observe container
58
+
59
+
60
+    swiper.observer.attach(swiper.$el[0], {
61
+      childList: swiper.params.observeSlideChildren
62
+    }); // Observe wrapper
63
+
64
+    swiper.observer.attach(swiper.$wrapperEl[0], {
65
+      attributes: false
66
+    });
67
+  },
68
+  destroy: function destroy() {
69
+    var swiper = this;
70
+    swiper.observer.observers.forEach(function (observer) {
71
+      observer.disconnect();
72
+    });
73
+    swiper.observer.observers = [];
74
+  }
75
+};
76
+var _default = {
77
+  name: 'observer',
78
+  params: {
79
+    observer: false,
80
+    observeParents: false,
81
+    observeSlideChildren: false
82
+  },
83
+  create: function create() {
84
+    var swiper = this;
85
+    (0, _utils.bindModuleMethods)(swiper, {
86
+      observer: _extends({}, Observer, {
87
+        observers: []
88
+      })
89
+    });
90
+  },
91
+  on: {
92
+    init: function init(swiper) {
93
+      swiper.observer.init();
94
+    },
95
+    destroy: function destroy(swiper) {
96
+      swiper.observer.destroy();
97
+    }
98
+  }
99
+};
100
+exports.default = _default;
0 101
\ No newline at end of file