Browse code

Remove old version 5

Benjamin Roth authored on14/03/2021 15:27:00
Showing1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,171 +0,0 @@
1
-import $ from '../../utils/dom';
2
-import Utils from '../../utils/utils';
3
-
4
-const Navigation = {
5
-  update() {
6
-    // Update Navigation Buttons
7
-    const swiper = this;
8
-    const params = swiper.params.navigation;
9
-
10
-    if (swiper.params.loop) return;
11
-    const { $nextEl, $prevEl } = swiper.navigation;
12
-
13
-    if ($prevEl && $prevEl.length > 0) {
14
-      if (swiper.isBeginning) {
15
-        $prevEl.addClass(params.disabledClass);
16
-      } else {
17
-        $prevEl.removeClass(params.disabledClass);
18
-      }
19
-      $prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
20
-    }
21
-    if ($nextEl && $nextEl.length > 0) {
22
-      if (swiper.isEnd) {
23
-        $nextEl.addClass(params.disabledClass);
24
-      } else {
25
-        $nextEl.removeClass(params.disabledClass);
26
-      }
27
-      $nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
28
-    }
29
-  },
30
-  onPrevClick(e) {
31
-    const swiper = this;
32
-    e.preventDefault();
33
-    if (swiper.isBeginning && !swiper.params.loop) return;
34
-    swiper.slidePrev();
35
-  },
36
-  onNextClick(e) {
37
-    const swiper = this;
38
-    e.preventDefault();
39
-    if (swiper.isEnd && !swiper.params.loop) return;
40
-    swiper.slideNext();
41
-  },
42
-  init() {
43
-    const swiper = this;
44
-    const params = swiper.params.navigation;
45
-    if (!(params.nextEl || params.prevEl)) return;
46
-
47
-    let $nextEl;
48
-    let $prevEl;
49
-    if (params.nextEl) {
50
-      $nextEl = $(params.nextEl);
51
-      if (
52
-        swiper.params.uniqueNavElements
53
-        && typeof params.nextEl === 'string'
54
-        && $nextEl.length > 1
55
-        && swiper.$el.find(params.nextEl).length === 1
56
-      ) {
57
-        $nextEl = swiper.$el.find(params.nextEl);
58
-      }
59
-    }
60
-    if (params.prevEl) {
61
-      $prevEl = $(params.prevEl);
62
-      if (
63
-        swiper.params.uniqueNavElements
64
-        && typeof params.prevEl === 'string'
65
-        && $prevEl.length > 1
66
-        && swiper.$el.find(params.prevEl).length === 1
67
-      ) {
68
-        $prevEl = swiper.$el.find(params.prevEl);
69
-      }
70
-    }
71
-
72
-    if ($nextEl && $nextEl.length > 0) {
73
-      $nextEl.on('click', swiper.navigation.onNextClick);
74
-    }
75
-    if ($prevEl && $prevEl.length > 0) {
76
-      $prevEl.on('click', swiper.navigation.onPrevClick);
77
-    }
78
-
79
-    Utils.extend(swiper.navigation, {
80
-      $nextEl,
81
-      nextEl: $nextEl && $nextEl[0],
82
-      $prevEl,
83
-      prevEl: $prevEl && $prevEl[0],
84
-    });
85
-  },
86
-  destroy() {
87
-    const swiper = this;
88
-    const { $nextEl, $prevEl } = swiper.navigation;
89
-    if ($nextEl && $nextEl.length) {
90
-      $nextEl.off('click', swiper.navigation.onNextClick);
91
-      $nextEl.removeClass(swiper.params.navigation.disabledClass);
92
-    }
93
-    if ($prevEl && $prevEl.length) {
94
-      $prevEl.off('click', swiper.navigation.onPrevClick);
95
-      $prevEl.removeClass(swiper.params.navigation.disabledClass);
96
-    }
97
-  },
98
-};
99
-
100
-export default {
101
-  name: 'navigation',
102
-  params: {
103
-    navigation: {
104
-      nextEl: null,
105
-      prevEl: null,
106
-
107
-      hideOnClick: false,
108
-      disabledClass: 'swiper-button-disabled',
109
-      hiddenClass: 'swiper-button-hidden',
110
-      lockClass: 'swiper-button-lock',
111
-    },
112
-  },
113
-  create() {
114
-    const swiper = this;
115
-    Utils.extend(swiper, {
116
-      navigation: {
117
-        init: Navigation.init.bind(swiper),
118
-        update: Navigation.update.bind(swiper),
119
-        destroy: Navigation.destroy.bind(swiper),
120
-        onNextClick: Navigation.onNextClick.bind(swiper),
121
-        onPrevClick: Navigation.onPrevClick.bind(swiper),
122
-      },
123
-    });
124
-  },
125
-  on: {
126
-    init() {
127
-      const swiper = this;
128
-      swiper.navigation.init();
129
-      swiper.navigation.update();
130
-    },
131
-    toEdge() {
132
-      const swiper = this;
133
-      swiper.navigation.update();
134
-    },
135
-    fromEdge() {
136
-      const swiper = this;
137
-      swiper.navigation.update();
138
-    },
139
-    destroy() {
140
-      const swiper = this;
141
-      swiper.navigation.destroy();
142
-    },
143
-    click(e) {
144
-      const swiper = this;
145
-      const { $nextEl, $prevEl } = swiper.navigation;
146
-      if (
147
-        swiper.params.navigation.hideOnClick
148
-        && !$(e.target).is($prevEl)
149
-        && !$(e.target).is($nextEl)
150
-      ) {
151
-        let isHidden;
152
-        if ($nextEl) {
153
-          isHidden = $nextEl.hasClass(swiper.params.navigation.hiddenClass);
154
-        } else if ($prevEl) {
155
-          isHidden = $prevEl.hasClass(swiper.params.navigation.hiddenClass);
156
-        }
157
-        if (isHidden === true) {
158
-          swiper.emit('navigationShow', swiper);
159
-        } else {
160
-          swiper.emit('navigationHide', swiper);
161
-        }
162
-        if ($nextEl) {
163
-          $nextEl.toggleClass(swiper.params.navigation.hiddenClass);
164
-        }
165
-        if ($prevEl) {
166
-          $prevEl.toggleClass(swiper.params.navigation.hiddenClass);
167
-        }
168
-      }
169
-    },
170
-  },
171
-};
Browse code

Initial commit

Benjamin Roth authored on19/05/2020 21:59:44
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,171 @@
1
+import $ from '../../utils/dom';
2
+import Utils from '../../utils/utils';
3
+
4
+const Navigation = {
5
+  update() {
6
+    // Update Navigation Buttons
7
+    const swiper = this;
8
+    const params = swiper.params.navigation;
9
+
10
+    if (swiper.params.loop) return;
11
+    const { $nextEl, $prevEl } = swiper.navigation;
12
+
13
+    if ($prevEl && $prevEl.length > 0) {
14
+      if (swiper.isBeginning) {
15
+        $prevEl.addClass(params.disabledClass);
16
+      } else {
17
+        $prevEl.removeClass(params.disabledClass);
18
+      }
19
+      $prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
20
+    }
21
+    if ($nextEl && $nextEl.length > 0) {
22
+      if (swiper.isEnd) {
23
+        $nextEl.addClass(params.disabledClass);
24
+      } else {
25
+        $nextEl.removeClass(params.disabledClass);
26
+      }
27
+      $nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
28
+    }
29
+  },
30
+  onPrevClick(e) {
31
+    const swiper = this;
32
+    e.preventDefault();
33
+    if (swiper.isBeginning && !swiper.params.loop) return;
34
+    swiper.slidePrev();
35
+  },
36
+  onNextClick(e) {
37
+    const swiper = this;
38
+    e.preventDefault();
39
+    if (swiper.isEnd && !swiper.params.loop) return;
40
+    swiper.slideNext();
41
+  },
42
+  init() {
43
+    const swiper = this;
44
+    const params = swiper.params.navigation;
45
+    if (!(params.nextEl || params.prevEl)) return;
46
+
47
+    let $nextEl;
48
+    let $prevEl;
49
+    if (params.nextEl) {
50
+      $nextEl = $(params.nextEl);
51
+      if (
52
+        swiper.params.uniqueNavElements
53
+        && typeof params.nextEl === 'string'
54
+        && $nextEl.length > 1
55
+        && swiper.$el.find(params.nextEl).length === 1
56
+      ) {
57
+        $nextEl = swiper.$el.find(params.nextEl);
58
+      }
59
+    }
60
+    if (params.prevEl) {
61
+      $prevEl = $(params.prevEl);
62
+      if (
63
+        swiper.params.uniqueNavElements
64
+        && typeof params.prevEl === 'string'
65
+        && $prevEl.length > 1
66
+        && swiper.$el.find(params.prevEl).length === 1
67
+      ) {
68
+        $prevEl = swiper.$el.find(params.prevEl);
69
+      }
70
+    }
71
+
72
+    if ($nextEl && $nextEl.length > 0) {
73
+      $nextEl.on('click', swiper.navigation.onNextClick);
74
+    }
75
+    if ($prevEl && $prevEl.length > 0) {
76
+      $prevEl.on('click', swiper.navigation.onPrevClick);
77
+    }
78
+
79
+    Utils.extend(swiper.navigation, {
80
+      $nextEl,
81
+      nextEl: $nextEl && $nextEl[0],
82
+      $prevEl,
83
+      prevEl: $prevEl && $prevEl[0],
84
+    });
85
+  },
86
+  destroy() {
87
+    const swiper = this;
88
+    const { $nextEl, $prevEl } = swiper.navigation;
89
+    if ($nextEl && $nextEl.length) {
90
+      $nextEl.off('click', swiper.navigation.onNextClick);
91
+      $nextEl.removeClass(swiper.params.navigation.disabledClass);
92
+    }
93
+    if ($prevEl && $prevEl.length) {
94
+      $prevEl.off('click', swiper.navigation.onPrevClick);
95
+      $prevEl.removeClass(swiper.params.navigation.disabledClass);
96
+    }
97
+  },
98
+};
99
+
100
+export default {
101
+  name: 'navigation',
102
+  params: {
103
+    navigation: {
104
+      nextEl: null,
105
+      prevEl: null,
106
+
107
+      hideOnClick: false,
108
+      disabledClass: 'swiper-button-disabled',
109
+      hiddenClass: 'swiper-button-hidden',
110
+      lockClass: 'swiper-button-lock',
111
+    },
112
+  },
113
+  create() {
114
+    const swiper = this;
115
+    Utils.extend(swiper, {
116
+      navigation: {
117
+        init: Navigation.init.bind(swiper),
118
+        update: Navigation.update.bind(swiper),
119
+        destroy: Navigation.destroy.bind(swiper),
120
+        onNextClick: Navigation.onNextClick.bind(swiper),
121
+        onPrevClick: Navigation.onPrevClick.bind(swiper),
122
+      },
123
+    });
124
+  },
125
+  on: {
126
+    init() {
127
+      const swiper = this;
128
+      swiper.navigation.init();
129
+      swiper.navigation.update();
130
+    },
131
+    toEdge() {
132
+      const swiper = this;
133
+      swiper.navigation.update();
134
+    },
135
+    fromEdge() {
136
+      const swiper = this;
137
+      swiper.navigation.update();
138
+    },
139
+    destroy() {
140
+      const swiper = this;
141
+      swiper.navigation.destroy();
142
+    },
143
+    click(e) {
144
+      const swiper = this;
145
+      const { $nextEl, $prevEl } = swiper.navigation;
146
+      if (
147
+        swiper.params.navigation.hideOnClick
148
+        && !$(e.target).is($prevEl)
149
+        && !$(e.target).is($nextEl)
150
+      ) {
151
+        let isHidden;
152
+        if ($nextEl) {
153
+          isHidden = $nextEl.hasClass(swiper.params.navigation.hiddenClass);
154
+        } else if ($prevEl) {
155
+          isHidden = $prevEl.hasClass(swiper.params.navigation.hiddenClass);
156
+        }
157
+        if (isHidden === true) {
158
+          swiper.emit('navigationShow', swiper);
159
+        } else {
160
+          swiper.emit('navigationHide', swiper);
161
+        }
162
+        if ($nextEl) {
163
+          $nextEl.toggleClass(swiper.params.navigation.hiddenClass);
164
+        }
165
+        if ($prevEl) {
166
+          $prevEl.toggleClass(swiper.params.navigation.hiddenClass);
167
+        }
168
+      }
169
+    },
170
+  },
171
+};