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