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,333 +0,0 @@
1
-import { document } from 'ssr-window';
2
-import $ from '../../utils/dom';
3
-import Utils from '../../utils/utils';
4
-import Support from '../../utils/support';
5
-
6
-const Scrollbar = {
7
-  setTranslate() {
8
-    const swiper = this;
9
-    if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
10
-    const { scrollbar, rtlTranslate: rtl, progress } = swiper;
11
-    const {
12
-      dragSize, trackSize, $dragEl, $el,
13
-    } = scrollbar;
14
-    const params = swiper.params.scrollbar;
15
-
16
-    let newSize = dragSize;
17
-    let newPos = (trackSize - dragSize) * progress;
18
-    if (rtl) {
19
-      newPos = -newPos;
20
-      if (newPos > 0) {
21
-        newSize = dragSize - newPos;
22
-        newPos = 0;
23
-      } else if (-newPos + dragSize > trackSize) {
24
-        newSize = trackSize + newPos;
25
-      }
26
-    } else if (newPos < 0) {
27
-      newSize = dragSize + newPos;
28
-      newPos = 0;
29
-    } else if (newPos + dragSize > trackSize) {
30
-      newSize = trackSize - newPos;
31
-    }
32
-    if (swiper.isHorizontal()) {
33
-      $dragEl.transform(`translate3d(${newPos}px, 0, 0)`);
34
-      $dragEl[0].style.width = `${newSize}px`;
35
-    } else {
36
-      $dragEl.transform(`translate3d(0px, ${newPos}px, 0)`);
37
-      $dragEl[0].style.height = `${newSize}px`;
38
-    }
39
-    if (params.hide) {
40
-      clearTimeout(swiper.scrollbar.timeout);
41
-      $el[0].style.opacity = 1;
42
-      swiper.scrollbar.timeout = setTimeout(() => {
43
-        $el[0].style.opacity = 0;
44
-        $el.transition(400);
45
-      }, 1000);
46
-    }
47
-  },
48
-  setTransition(duration) {
49
-    const swiper = this;
50
-    if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
51
-    swiper.scrollbar.$dragEl.transition(duration);
52
-  },
53
-  updateSize() {
54
-    const swiper = this;
55
-    if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
56
-
57
-    const { scrollbar } = swiper;
58
-    const { $dragEl, $el } = scrollbar;
59
-
60
-    $dragEl[0].style.width = '';
61
-    $dragEl[0].style.height = '';
62
-    const trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight;
63
-
64
-    const divider = swiper.size / swiper.virtualSize;
65
-    const moveDivider = divider * (trackSize / swiper.size);
66
-    let dragSize;
67
-    if (swiper.params.scrollbar.dragSize === 'auto') {
68
-      dragSize = trackSize * divider;
69
-    } else {
70
-      dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);
71
-    }
72
-
73
-    if (swiper.isHorizontal()) {
74
-      $dragEl[0].style.width = `${dragSize}px`;
75
-    } else {
76
-      $dragEl[0].style.height = `${dragSize}px`;
77
-    }
78
-
79
-    if (divider >= 1) {
80
-      $el[0].style.display = 'none';
81
-    } else {
82
-      $el[0].style.display = '';
83
-    }
84
-    if (swiper.params.scrollbar.hide) {
85
-      $el[0].style.opacity = 0;
86
-    }
87
-    Utils.extend(scrollbar, {
88
-      trackSize,
89
-      divider,
90
-      moveDivider,
91
-      dragSize,
92
-    });
93
-    scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass);
94
-  },
95
-  getPointerPosition(e) {
96
-    const swiper = this;
97
-    if (swiper.isHorizontal()) {
98
-      return ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].clientX : e.clientX);
99
-    }
100
-    return ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].clientY : e.clientY);
101
-  },
102
-  setDragPosition(e) {
103
-    const swiper = this;
104
-    const { scrollbar, rtlTranslate: rtl } = swiper;
105
-    const {
106
-      $el,
107
-      dragSize,
108
-      trackSize,
109
-      dragStartPos,
110
-    } = scrollbar;
111
-
112
-    let positionRatio;
113
-    positionRatio = ((scrollbar.getPointerPosition(e)) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top']
114
-      - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize);
115
-    positionRatio = Math.max(Math.min(positionRatio, 1), 0);
116
-    if (rtl) {
117
-      positionRatio = 1 - positionRatio;
118
-    }
119
-
120
-    const position = swiper.minTranslate() + ((swiper.maxTranslate() - swiper.minTranslate()) * positionRatio);
121
-
122
-    swiper.updateProgress(position);
123
-    swiper.setTranslate(position);
124
-    swiper.updateActiveIndex();
125
-    swiper.updateSlidesClasses();
126
-  },
127
-  onDragStart(e) {
128
-    const swiper = this;
129
-    const params = swiper.params.scrollbar;
130
-    const { scrollbar, $wrapperEl } = swiper;
131
-    const { $el, $dragEl } = scrollbar;
132
-    swiper.scrollbar.isTouched = true;
133
-    swiper.scrollbar.dragStartPos = (e.target === $dragEl[0] || e.target === $dragEl)
134
-      ? scrollbar.getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null;
135
-    e.preventDefault();
136
-    e.stopPropagation();
137
-
138
-    $wrapperEl.transition(100);
139
-    $dragEl.transition(100);
140
-    scrollbar.setDragPosition(e);
141
-
142
-    clearTimeout(swiper.scrollbar.dragTimeout);
143
-
144
-    $el.transition(0);
145
-    if (params.hide) {
146
-      $el.css('opacity', 1);
147
-    }
148
-    if (swiper.params.cssMode) {
149
-      swiper.$wrapperEl.css('scroll-snap-type', 'none');
150
-    }
151
-    swiper.emit('scrollbarDragStart', e);
152
-  },
153
-  onDragMove(e) {
154
-    const swiper = this;
155
-    const { scrollbar, $wrapperEl } = swiper;
156
-    const { $el, $dragEl } = scrollbar;
157
-
158
-    if (!swiper.scrollbar.isTouched) return;
159
-    if (e.preventDefault) e.preventDefault();
160
-    else e.returnValue = false;
161
-    scrollbar.setDragPosition(e);
162
-    $wrapperEl.transition(0);
163
-    $el.transition(0);
164
-    $dragEl.transition(0);
165
-    swiper.emit('scrollbarDragMove', e);
166
-  },
167
-  onDragEnd(e) {
168
-    const swiper = this;
169
-
170
-    const params = swiper.params.scrollbar;
171
-    const { scrollbar, $wrapperEl } = swiper;
172
-    const { $el } = scrollbar;
173
-
174
-    if (!swiper.scrollbar.isTouched) return;
175
-    swiper.scrollbar.isTouched = false;
176
-    if (swiper.params.cssMode) {
177
-      swiper.$wrapperEl.css('scroll-snap-type', '');
178
-      $wrapperEl.transition('');
179
-    }
180
-    if (params.hide) {
181
-      clearTimeout(swiper.scrollbar.dragTimeout);
182
-      swiper.scrollbar.dragTimeout = Utils.nextTick(() => {
183
-        $el.css('opacity', 0);
184
-        $el.transition(400);
185
-      }, 1000);
186
-    }
187
-    swiper.emit('scrollbarDragEnd', e);
188
-    if (params.snapOnRelease) {
189
-      swiper.slideToClosest();
190
-    }
191
-  },
192
-  enableDraggable() {
193
-    const swiper = this;
194
-    if (!swiper.params.scrollbar.el) return;
195
-    const {
196
-      scrollbar, touchEventsTouch, touchEventsDesktop, params,
197
-    } = swiper;
198
-    const $el = scrollbar.$el;
199
-    const target = $el[0];
200
-    const activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false;
201
-    const passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
202
-    if (!Support.touch) {
203
-      target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
204
-      document.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
205
-      document.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
206
-    } else {
207
-      target.addEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
208
-      target.addEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
209
-      target.addEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
210
-    }
211
-  },
212
-  disableDraggable() {
213
-    const swiper = this;
214
-    if (!swiper.params.scrollbar.el) return;
215
-    const {
216
-      scrollbar, touchEventsTouch, touchEventsDesktop, params,
217
-    } = swiper;
218
-    const $el = scrollbar.$el;
219
-    const target = $el[0];
220
-    const activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false;
221
-    const passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
222
-    if (!Support.touch) {
223
-      target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
224
-      document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
225
-      document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
226
-    } else {
227
-      target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
228
-      target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
229
-      target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
230
-    }
231
-  },
232
-  init() {
233
-    const swiper = this;
234
-    if (!swiper.params.scrollbar.el) return;
235
-    const { scrollbar, $el: $swiperEl } = swiper;
236
-    const params = swiper.params.scrollbar;
237
-
238
-    let $el = $(params.el);
239
-    if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) {
240
-      $el = $swiperEl.find(params.el);
241
-    }
242
-
243
-    let $dragEl = $el.find(`.${swiper.params.scrollbar.dragClass}`);
244
-    if ($dragEl.length === 0) {
245
-      $dragEl = $(`<div class="${swiper.params.scrollbar.dragClass}"></div>`);
246
-      $el.append($dragEl);
247
-    }
248
-
249
-    Utils.extend(scrollbar, {
250
-      $el,
251
-      el: $el[0],
252
-      $dragEl,
253
-      dragEl: $dragEl[0],
254
-    });
255
-
256
-    if (params.draggable) {
257
-      scrollbar.enableDraggable();
258
-    }
259
-  },
260
-  destroy() {
261
-    const swiper = this;
262
-    swiper.scrollbar.disableDraggable();
263
-  },
264
-};
265
-
266
-export default {
267
-  name: 'scrollbar',
268
-  params: {
269
-    scrollbar: {
270
-      el: null,
271
-      dragSize: 'auto',
272
-      hide: false,
273
-      draggable: false,
274
-      snapOnRelease: true,
275
-      lockClass: 'swiper-scrollbar-lock',
276
-      dragClass: 'swiper-scrollbar-drag',
277
-    },
278
-  },
279
-  create() {
280
-    const swiper = this;
281
-    Utils.extend(swiper, {
282
-      scrollbar: {
283
-        init: Scrollbar.init.bind(swiper),
284
-        destroy: Scrollbar.destroy.bind(swiper),
285
-        updateSize: Scrollbar.updateSize.bind(swiper),
286
-        setTranslate: Scrollbar.setTranslate.bind(swiper),
287
-        setTransition: Scrollbar.setTransition.bind(swiper),
288
-        enableDraggable: Scrollbar.enableDraggable.bind(swiper),
289
-        disableDraggable: Scrollbar.disableDraggable.bind(swiper),
290
-        setDragPosition: Scrollbar.setDragPosition.bind(swiper),
291
-        getPointerPosition: Scrollbar.getPointerPosition.bind(swiper),
292
-        onDragStart: Scrollbar.onDragStart.bind(swiper),
293
-        onDragMove: Scrollbar.onDragMove.bind(swiper),
294
-        onDragEnd: Scrollbar.onDragEnd.bind(swiper),
295
-        isTouched: false,
296
-        timeout: null,
297
-        dragTimeout: null,
298
-      },
299
-    });
300
-  },
301
-  on: {
302
-    init() {
303
-      const swiper = this;
304
-      swiper.scrollbar.init();
305
-      swiper.scrollbar.updateSize();
306
-      swiper.scrollbar.setTranslate();
307
-    },
308
-    update() {
309
-      const swiper = this;
310
-      swiper.scrollbar.updateSize();
311
-    },
312
-    resize() {
313
-      const swiper = this;
314
-      swiper.scrollbar.updateSize();
315
-    },
316
-    observerUpdate() {
317
-      const swiper = this;
318
-      swiper.scrollbar.updateSize();
319
-    },
320
-    setTranslate() {
321
-      const swiper = this;
322
-      swiper.scrollbar.setTranslate();
323
-    },
324
-    setTransition(duration) {
325
-      const swiper = this;
326
-      swiper.scrollbar.setTransition(duration);
327
-    },
328
-    destroy() {
329
-      const swiper = this;
330
-      swiper.scrollbar.destroy();
331
-    },
332
-  },
333
-};
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,333 @@
1
+import { document } from 'ssr-window';
2
+import $ from '../../utils/dom';
3
+import Utils from '../../utils/utils';
4
+import Support from '../../utils/support';
5
+
6
+const Scrollbar = {
7
+  setTranslate() {
8
+    const swiper = this;
9
+    if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
10
+    const { scrollbar, rtlTranslate: rtl, progress } = swiper;
11
+    const {
12
+      dragSize, trackSize, $dragEl, $el,
13
+    } = scrollbar;
14
+    const params = swiper.params.scrollbar;
15
+
16
+    let newSize = dragSize;
17
+    let newPos = (trackSize - dragSize) * progress;
18
+    if (rtl) {
19
+      newPos = -newPos;
20
+      if (newPos > 0) {
21
+        newSize = dragSize - newPos;
22
+        newPos = 0;
23
+      } else if (-newPos + dragSize > trackSize) {
24
+        newSize = trackSize + newPos;
25
+      }
26
+    } else if (newPos < 0) {
27
+      newSize = dragSize + newPos;
28
+      newPos = 0;
29
+    } else if (newPos + dragSize > trackSize) {
30
+      newSize = trackSize - newPos;
31
+    }
32
+    if (swiper.isHorizontal()) {
33
+      $dragEl.transform(`translate3d(${newPos}px, 0, 0)`);
34
+      $dragEl[0].style.width = `${newSize}px`;
35
+    } else {
36
+      $dragEl.transform(`translate3d(0px, ${newPos}px, 0)`);
37
+      $dragEl[0].style.height = `${newSize}px`;
38
+    }
39
+    if (params.hide) {
40
+      clearTimeout(swiper.scrollbar.timeout);
41
+      $el[0].style.opacity = 1;
42
+      swiper.scrollbar.timeout = setTimeout(() => {
43
+        $el[0].style.opacity = 0;
44
+        $el.transition(400);
45
+      }, 1000);
46
+    }
47
+  },
48
+  setTransition(duration) {
49
+    const swiper = this;
50
+    if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
51
+    swiper.scrollbar.$dragEl.transition(duration);
52
+  },
53
+  updateSize() {
54
+    const swiper = this;
55
+    if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
56
+
57
+    const { scrollbar } = swiper;
58
+    const { $dragEl, $el } = scrollbar;
59
+
60
+    $dragEl[0].style.width = '';
61
+    $dragEl[0].style.height = '';
62
+    const trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight;
63
+
64
+    const divider = swiper.size / swiper.virtualSize;
65
+    const moveDivider = divider * (trackSize / swiper.size);
66
+    let dragSize;
67
+    if (swiper.params.scrollbar.dragSize === 'auto') {
68
+      dragSize = trackSize * divider;
69
+    } else {
70
+      dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);
71
+    }
72
+
73
+    if (swiper.isHorizontal()) {
74
+      $dragEl[0].style.width = `${dragSize}px`;
75
+    } else {
76
+      $dragEl[0].style.height = `${dragSize}px`;
77
+    }
78
+
79
+    if (divider >= 1) {
80
+      $el[0].style.display = 'none';
81
+    } else {
82
+      $el[0].style.display = '';
83
+    }
84
+    if (swiper.params.scrollbar.hide) {
85
+      $el[0].style.opacity = 0;
86
+    }
87
+    Utils.extend(scrollbar, {
88
+      trackSize,
89
+      divider,
90
+      moveDivider,
91
+      dragSize,
92
+    });
93
+    scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass);
94
+  },
95
+  getPointerPosition(e) {
96
+    const swiper = this;
97
+    if (swiper.isHorizontal()) {
98
+      return ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].clientX : e.clientX);
99
+    }
100
+    return ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].clientY : e.clientY);
101
+  },
102
+  setDragPosition(e) {
103
+    const swiper = this;
104
+    const { scrollbar, rtlTranslate: rtl } = swiper;
105
+    const {
106
+      $el,
107
+      dragSize,
108
+      trackSize,
109
+      dragStartPos,
110
+    } = scrollbar;
111
+
112
+    let positionRatio;
113
+    positionRatio = ((scrollbar.getPointerPosition(e)) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top']
114
+      - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize);
115
+    positionRatio = Math.max(Math.min(positionRatio, 1), 0);
116
+    if (rtl) {
117
+      positionRatio = 1 - positionRatio;
118
+    }
119
+
120
+    const position = swiper.minTranslate() + ((swiper.maxTranslate() - swiper.minTranslate()) * positionRatio);
121
+
122
+    swiper.updateProgress(position);
123
+    swiper.setTranslate(position);
124
+    swiper.updateActiveIndex();
125
+    swiper.updateSlidesClasses();
126
+  },
127
+  onDragStart(e) {
128
+    const swiper = this;
129
+    const params = swiper.params.scrollbar;
130
+    const { scrollbar, $wrapperEl } = swiper;
131
+    const { $el, $dragEl } = scrollbar;
132
+    swiper.scrollbar.isTouched = true;
133
+    swiper.scrollbar.dragStartPos = (e.target === $dragEl[0] || e.target === $dragEl)
134
+      ? scrollbar.getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null;
135
+    e.preventDefault();
136
+    e.stopPropagation();
137
+
138
+    $wrapperEl.transition(100);
139
+    $dragEl.transition(100);
140
+    scrollbar.setDragPosition(e);
141
+
142
+    clearTimeout(swiper.scrollbar.dragTimeout);
143
+
144
+    $el.transition(0);
145
+    if (params.hide) {
146
+      $el.css('opacity', 1);
147
+    }
148
+    if (swiper.params.cssMode) {
149
+      swiper.$wrapperEl.css('scroll-snap-type', 'none');
150
+    }
151
+    swiper.emit('scrollbarDragStart', e);
152
+  },
153
+  onDragMove(e) {
154
+    const swiper = this;
155
+    const { scrollbar, $wrapperEl } = swiper;
156
+    const { $el, $dragEl } = scrollbar;
157
+
158
+    if (!swiper.scrollbar.isTouched) return;
159
+    if (e.preventDefault) e.preventDefault();
160
+    else e.returnValue = false;
161
+    scrollbar.setDragPosition(e);
162
+    $wrapperEl.transition(0);
163
+    $el.transition(0);
164
+    $dragEl.transition(0);
165
+    swiper.emit('scrollbarDragMove', e);
166
+  },
167
+  onDragEnd(e) {
168
+    const swiper = this;
169
+
170
+    const params = swiper.params.scrollbar;
171
+    const { scrollbar, $wrapperEl } = swiper;
172
+    const { $el } = scrollbar;
173
+
174
+    if (!swiper.scrollbar.isTouched) return;
175
+    swiper.scrollbar.isTouched = false;
176
+    if (swiper.params.cssMode) {
177
+      swiper.$wrapperEl.css('scroll-snap-type', '');
178
+      $wrapperEl.transition('');
179
+    }
180
+    if (params.hide) {
181
+      clearTimeout(swiper.scrollbar.dragTimeout);
182
+      swiper.scrollbar.dragTimeout = Utils.nextTick(() => {
183
+        $el.css('opacity', 0);
184
+        $el.transition(400);
185
+      }, 1000);
186
+    }
187
+    swiper.emit('scrollbarDragEnd', e);
188
+    if (params.snapOnRelease) {
189
+      swiper.slideToClosest();
190
+    }
191
+  },
192
+  enableDraggable() {
193
+    const swiper = this;
194
+    if (!swiper.params.scrollbar.el) return;
195
+    const {
196
+      scrollbar, touchEventsTouch, touchEventsDesktop, params,
197
+    } = swiper;
198
+    const $el = scrollbar.$el;
199
+    const target = $el[0];
200
+    const activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false;
201
+    const passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
202
+    if (!Support.touch) {
203
+      target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
204
+      document.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
205
+      document.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
206
+    } else {
207
+      target.addEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
208
+      target.addEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
209
+      target.addEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
210
+    }
211
+  },
212
+  disableDraggable() {
213
+    const swiper = this;
214
+    if (!swiper.params.scrollbar.el) return;
215
+    const {
216
+      scrollbar, touchEventsTouch, touchEventsDesktop, params,
217
+    } = swiper;
218
+    const $el = scrollbar.$el;
219
+    const target = $el[0];
220
+    const activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false;
221
+    const passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false;
222
+    if (!Support.touch) {
223
+      target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
224
+      document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
225
+      document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
226
+    } else {
227
+      target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
228
+      target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
229
+      target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
230
+    }
231
+  },
232
+  init() {
233
+    const swiper = this;
234
+    if (!swiper.params.scrollbar.el) return;
235
+    const { scrollbar, $el: $swiperEl } = swiper;
236
+    const params = swiper.params.scrollbar;
237
+
238
+    let $el = $(params.el);
239
+    if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) {
240
+      $el = $swiperEl.find(params.el);
241
+    }
242
+
243
+    let $dragEl = $el.find(`.${swiper.params.scrollbar.dragClass}`);
244
+    if ($dragEl.length === 0) {
245
+      $dragEl = $(`<div class="${swiper.params.scrollbar.dragClass}"></div>`);
246
+      $el.append($dragEl);
247
+    }
248
+
249
+    Utils.extend(scrollbar, {
250
+      $el,
251
+      el: $el[0],
252
+      $dragEl,
253
+      dragEl: $dragEl[0],
254
+    });
255
+
256
+    if (params.draggable) {
257
+      scrollbar.enableDraggable();
258
+    }
259
+  },
260
+  destroy() {
261
+    const swiper = this;
262
+    swiper.scrollbar.disableDraggable();
263
+  },
264
+};
265
+
266
+export default {
267
+  name: 'scrollbar',
268
+  params: {
269
+    scrollbar: {
270
+      el: null,
271
+      dragSize: 'auto',
272
+      hide: false,
273
+      draggable: false,
274
+      snapOnRelease: true,
275
+      lockClass: 'swiper-scrollbar-lock',
276
+      dragClass: 'swiper-scrollbar-drag',
277
+    },
278
+  },
279
+  create() {
280
+    const swiper = this;
281
+    Utils.extend(swiper, {
282
+      scrollbar: {
283
+        init: Scrollbar.init.bind(swiper),
284
+        destroy: Scrollbar.destroy.bind(swiper),
285
+        updateSize: Scrollbar.updateSize.bind(swiper),
286
+        setTranslate: Scrollbar.setTranslate.bind(swiper),
287
+        setTransition: Scrollbar.setTransition.bind(swiper),
288
+        enableDraggable: Scrollbar.enableDraggable.bind(swiper),
289
+        disableDraggable: Scrollbar.disableDraggable.bind(swiper),
290
+        setDragPosition: Scrollbar.setDragPosition.bind(swiper),
291
+        getPointerPosition: Scrollbar.getPointerPosition.bind(swiper),
292
+        onDragStart: Scrollbar.onDragStart.bind(swiper),
293
+        onDragMove: Scrollbar.onDragMove.bind(swiper),
294
+        onDragEnd: Scrollbar.onDragEnd.bind(swiper),
295
+        isTouched: false,
296
+        timeout: null,
297
+        dragTimeout: null,
298
+      },
299
+    });
300
+  },
301
+  on: {
302
+    init() {
303
+      const swiper = this;
304
+      swiper.scrollbar.init();
305
+      swiper.scrollbar.updateSize();
306
+      swiper.scrollbar.setTranslate();
307
+    },
308
+    update() {
309
+      const swiper = this;
310
+      swiper.scrollbar.updateSize();
311
+    },
312
+    resize() {
313
+      const swiper = this;
314
+      swiper.scrollbar.updateSize();
315
+    },
316
+    observerUpdate() {
317
+      const swiper = this;
318
+      swiper.scrollbar.updateSize();
319
+    },
320
+    setTranslate() {
321
+      const swiper = this;
322
+      swiper.scrollbar.setTranslate();
323
+    },
324
+    setTransition(duration) {
325
+      const swiper = this;
326
+      swiper.scrollbar.setTransition(duration);
327
+    },
328
+    destroy() {
329
+      const swiper = this;
330
+      swiper.scrollbar.destroy();
331
+    },
332
+  },
333
+};