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

swiper.js version 6.3.3

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