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,121 +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 _dom = _interopRequireDefault(require("../../utils/dom"));
9
-
10
-var _utils = require("../../utils/utils");
11
-
12
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
-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); }
15
-
16
-var HashNavigation = {
17
-  onHashCange: function onHashCange() {
18
-    var swiper = this;
19
-    var document = (0, _ssrWindow.getDocument)();
20
-    swiper.emit('hashChange');
21
-    var newHash = document.location.hash.replace('#', '');
22
-    var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
23
-
24
-    if (newHash !== activeSlideHash) {
25
-      var newIndex = swiper.$wrapperEl.children("." + swiper.params.slideClass + "[data-hash=\"" + newHash + "\"]").index();
26
-      if (typeof newIndex === 'undefined') return;
27
-      swiper.slideTo(newIndex);
28
-    }
29
-  },
30
-  setHash: function setHash() {
31
-    var swiper = this;
32
-    var window = (0, _ssrWindow.getWindow)();
33
-    var document = (0, _ssrWindow.getDocument)();
34
-    if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) return;
35
-
36
-    if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
37
-      window.history.replaceState(null, null, "#" + swiper.slides.eq(swiper.activeIndex).attr('data-hash') || '');
38
-      swiper.emit('hashSet');
39
-    } else {
40
-      var slide = swiper.slides.eq(swiper.activeIndex);
41
-      var hash = slide.attr('data-hash') || slide.attr('data-history');
42
-      document.location.hash = hash || '';
43
-      swiper.emit('hashSet');
44
-    }
45
-  },
46
-  init: function init() {
47
-    var swiper = this;
48
-    var document = (0, _ssrWindow.getDocument)();
49
-    var window = (0, _ssrWindow.getWindow)();
50
-    if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
51
-    swiper.hashNavigation.initialized = true;
52
-    var hash = document.location.hash.replace('#', '');
53
-
54
-    if (hash) {
55
-      var speed = 0;
56
-
57
-      for (var i = 0, length = swiper.slides.length; i < length; i += 1) {
58
-        var slide = swiper.slides.eq(i);
59
-        var slideHash = slide.attr('data-hash') || slide.attr('data-history');
60
-
61
-        if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
62
-          var index = slide.index();
63
-          swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
64
-        }
65
-      }
66
-    }
67
-
68
-    if (swiper.params.hashNavigation.watchState) {
69
-      (0, _dom.default)(window).on('hashchange', swiper.hashNavigation.onHashCange);
70
-    }
71
-  },
72
-  destroy: function destroy() {
73
-    var swiper = this;
74
-    var window = (0, _ssrWindow.getWindow)();
75
-
76
-    if (swiper.params.hashNavigation.watchState) {
77
-      (0, _dom.default)(window).off('hashchange', swiper.hashNavigation.onHashCange);
78
-    }
79
-  }
80
-};
81
-var _default = {
82
-  name: 'hash-navigation',
83
-  params: {
84
-    hashNavigation: {
85
-      enabled: false,
86
-      replaceState: false,
87
-      watchState: false
88
-    }
89
-  },
90
-  create: function create() {
91
-    var swiper = this;
92
-    (0, _utils.bindModuleMethods)(swiper, {
93
-      hashNavigation: _extends({
94
-        initialized: false
95
-      }, HashNavigation)
96
-    });
97
-  },
98
-  on: {
99
-    init: function init(swiper) {
100
-      if (swiper.params.hashNavigation.enabled) {
101
-        swiper.hashNavigation.init();
102
-      }
103
-    },
104
-    destroy: function destroy(swiper) {
105
-      if (swiper.params.hashNavigation.enabled) {
106
-        swiper.hashNavigation.destroy();
107
-      }
108
-    },
109
-    transitionEnd: function transitionEnd(swiper) {
110
-      if (swiper.hashNavigation.initialized) {
111
-        swiper.hashNavigation.setHash();
112
-      }
113
-    },
114
-    slideChange: function slideChange(swiper) {
115
-      if (swiper.hashNavigation.initialized && swiper.params.cssMode) {
116
-        swiper.hashNavigation.setHash();
117
-      }
118
-    }
119
-  }
120
-};
121
-exports.default = _default;
122 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,121 @@
1
+"use strict";
2
+
3
+exports.__esModule = true;
4
+exports.default = void 0;
5
+
6
+var _ssrWindow = require("ssr-window");
7
+
8
+var _dom = _interopRequireDefault(require("../../utils/dom"));
9
+
10
+var _utils = require("../../utils/utils");
11
+
12
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+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); }
15
+
16
+var HashNavigation = {
17
+  onHashCange: function onHashCange() {
18
+    var swiper = this;
19
+    var document = (0, _ssrWindow.getDocument)();
20
+    swiper.emit('hashChange');
21
+    var newHash = document.location.hash.replace('#', '');
22
+    var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
23
+
24
+    if (newHash !== activeSlideHash) {
25
+      var newIndex = swiper.$wrapperEl.children("." + swiper.params.slideClass + "[data-hash=\"" + newHash + "\"]").index();
26
+      if (typeof newIndex === 'undefined') return;
27
+      swiper.slideTo(newIndex);
28
+    }
29
+  },
30
+  setHash: function setHash() {
31
+    var swiper = this;
32
+    var window = (0, _ssrWindow.getWindow)();
33
+    var document = (0, _ssrWindow.getDocument)();
34
+    if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) return;
35
+
36
+    if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
37
+      window.history.replaceState(null, null, "#" + swiper.slides.eq(swiper.activeIndex).attr('data-hash') || '');
38
+      swiper.emit('hashSet');
39
+    } else {
40
+      var slide = swiper.slides.eq(swiper.activeIndex);
41
+      var hash = slide.attr('data-hash') || slide.attr('data-history');
42
+      document.location.hash = hash || '';
43
+      swiper.emit('hashSet');
44
+    }
45
+  },
46
+  init: function init() {
47
+    var swiper = this;
48
+    var document = (0, _ssrWindow.getDocument)();
49
+    var window = (0, _ssrWindow.getWindow)();
50
+    if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
51
+    swiper.hashNavigation.initialized = true;
52
+    var hash = document.location.hash.replace('#', '');
53
+
54
+    if (hash) {
55
+      var speed = 0;
56
+
57
+      for (var i = 0, length = swiper.slides.length; i < length; i += 1) {
58
+        var slide = swiper.slides.eq(i);
59
+        var slideHash = slide.attr('data-hash') || slide.attr('data-history');
60
+
61
+        if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
62
+          var index = slide.index();
63
+          swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
64
+        }
65
+      }
66
+    }
67
+
68
+    if (swiper.params.hashNavigation.watchState) {
69
+      (0, _dom.default)(window).on('hashchange', swiper.hashNavigation.onHashCange);
70
+    }
71
+  },
72
+  destroy: function destroy() {
73
+    var swiper = this;
74
+    var window = (0, _ssrWindow.getWindow)();
75
+
76
+    if (swiper.params.hashNavigation.watchState) {
77
+      (0, _dom.default)(window).off('hashchange', swiper.hashNavigation.onHashCange);
78
+    }
79
+  }
80
+};
81
+var _default = {
82
+  name: 'hash-navigation',
83
+  params: {
84
+    hashNavigation: {
85
+      enabled: false,
86
+      replaceState: false,
87
+      watchState: false
88
+    }
89
+  },
90
+  create: function create() {
91
+    var swiper = this;
92
+    (0, _utils.bindModuleMethods)(swiper, {
93
+      hashNavigation: _extends({
94
+        initialized: false
95
+      }, HashNavigation)
96
+    });
97
+  },
98
+  on: {
99
+    init: function init(swiper) {
100
+      if (swiper.params.hashNavigation.enabled) {
101
+        swiper.hashNavigation.init();
102
+      }
103
+    },
104
+    destroy: function destroy(swiper) {
105
+      if (swiper.params.hashNavigation.enabled) {
106
+        swiper.hashNavigation.destroy();
107
+      }
108
+    },
109
+    transitionEnd: function transitionEnd(swiper) {
110
+      if (swiper.hashNavigation.initialized) {
111
+        swiper.hashNavigation.setHash();
112
+      }
113
+    },
114
+    slideChange: function slideChange(swiper) {
115
+      if (swiper.hashNavigation.initialized && swiper.params.cssMode) {
116
+        swiper.hashNavigation.setHash();
117
+      }
118
+    }
119
+  }
120
+};
121
+exports.default = _default;
0 122
\ No newline at end of file