@karta.io/simplebar 0.34.0-alpha.2 → 0.34.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,18 @@
1
1
  'use strict';
2
2
 
3
- const throttle = require('lodash/throttle');
4
- const debounce = require('lodash/debounce');
5
- const memoize = require('lodash/memoize');
3
+ const throttle = require('lodash/throttle.js');
4
+ const debounce = require('lodash/debounce.js');
5
+ const memoize = require('lodash/memoize.js');
6
6
  const resizeObserver = require('@juggle/resize-observer');
7
7
 
8
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
9
+
10
+ const throttle__default = /*#__PURE__*/_interopDefaultCompat(throttle);
11
+ const debounce__default = /*#__PURE__*/_interopDefaultCompat(debounce);
12
+ const memoize__default = /*#__PURE__*/_interopDefaultCompat(memoize);
13
+
8
14
  const canUseDOM = typeof window !== "undefined" && typeof window.document !== "undefined";
15
+ const canUseDOM$1 = canUseDOM;
9
16
 
10
17
  function getElementWindow(element) {
11
18
  if (!element || !element.ownerDocument || !element.ownerDocument.defaultView) {
@@ -22,7 +29,7 @@ function getElementDocument(element) {
22
29
 
23
30
  let cachedScrollbarWidth = null;
24
31
  let cachedDevicePixelRatio = null;
25
- if (canUseDOM) {
32
+ if (canUseDOM$1) {
26
33
  window.addEventListener("resize", () => {
27
34
  if (cachedDevicePixelRatio !== window.devicePixelRatio) {
28
35
  cachedDevicePixelRatio = window.devicePixelRatio;
@@ -56,6 +63,9 @@ var __publicField = (obj, key, value) => {
56
63
  };
57
64
  const _SimpleBar = class {
58
65
  constructor(element, options) {
66
+ /**
67
+ * On scroll event handling
68
+ */
59
69
  __publicField(this, "onScroll", () => {
60
70
  const elWindow = getElementWindow(this.el);
61
71
  if (!this.scrollXTicking) {
@@ -110,6 +120,9 @@ const _SimpleBar = class {
110
120
  this.scrollbarWidth = this.getScrollbarWidth();
111
121
  this.hideNativeScrollbar();
112
122
  });
123
+ /**
124
+ * Hide Scrollbar
125
+ */
113
126
  __publicField(this, "hideScrollbars", () => {
114
127
  this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
115
128
  this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
@@ -155,6 +168,9 @@ const _SimpleBar = class {
155
168
  }
156
169
  }
157
170
  });
171
+ /**
172
+ * Drag scrollbar handle
173
+ */
158
174
  __publicField(this, "drag", (e) => {
159
175
  let eventOffset;
160
176
  const track = this.axis[this.draggedAxis].track;
@@ -181,6 +197,9 @@ const _SimpleBar = class {
181
197
  }
182
198
  this.contentWrapperEl[this.axis[this.draggedAxis].scrollOffsetAttr] = scrollPos;
183
199
  });
200
+ /**
201
+ * End scroll handle drag
202
+ */
184
203
  __publicField(this, "onEndDrag", (e) => {
185
204
  const elDocument = getElementDocument(this.el);
186
205
  const elWindow = getElementWindow(this.el);
@@ -195,6 +214,9 @@ const _SimpleBar = class {
195
214
  this.removePreventClickId = null;
196
215
  });
197
216
  });
217
+ /**
218
+ * Handler to ignore click events during drag
219
+ */
198
220
  __publicField(this, "preventClick", (e) => {
199
221
  e.preventDefault();
200
222
  e.stopPropagation();
@@ -240,18 +262,27 @@ const _SimpleBar = class {
240
262
  if (_SimpleBar.instances.has(this.el)) {
241
263
  return;
242
264
  }
243
- this.recalculate = throttle(this.recalculate.bind(this), 64);
244
- this.onMouseMove = throttle(this.onMouseMove.bind(this), 64);
245
- this.hideScrollbars = debounce(
265
+ this.recalculate = throttle__default(this.recalculate.bind(this), 64);
266
+ this.onMouseMove = throttle__default(this.onMouseMove.bind(this), 64);
267
+ this.hideScrollbars = debounce__default(
246
268
  this.hideScrollbars.bind(this),
247
269
  this.options.timeout
248
270
  );
249
- this.onWindowResize = debounce(this.onWindowResize.bind(this), 64, {
271
+ this.onWindowResize = debounce__default(this.onWindowResize.bind(this), 64, {
250
272
  leading: true
251
273
  });
252
- _SimpleBar.getRtlHelpers = memoize(_SimpleBar.getRtlHelpers);
274
+ _SimpleBar.getRtlHelpers = memoize__default(_SimpleBar.getRtlHelpers);
253
275
  this.init();
254
276
  }
277
+ /**
278
+ * Static properties
279
+ */
280
+ /**
281
+ * Helper to fix browsers inconsistency on RTL:
282
+ * - Firefox inverts the scrollbar initial position
283
+ * - IE11 inverts both scrollbar position and scrolling offset
284
+ * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
285
+ */
255
286
  static getRtlHelpers() {
256
287
  const dummyDiv = document.createElement("div");
257
288
  dummyDiv.innerHTML = '<div class="hs-dummy-scrollbar-size"><div style="height: 200%; width: 200%; margin: 10px 0;"></div></div>';
@@ -266,7 +297,9 @@ const _SimpleBar = class {
266
297
  dummyContainerChild
267
298
  );
268
299
  return {
300
+ // determines if the scrolling is responding with negative values
269
301
  isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
302
+ // determines if the origin scrollbar position is inverted or not (positioned on left or right)
270
303
  isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
271
304
  };
272
305
  }
@@ -281,7 +314,7 @@ const _SimpleBar = class {
281
314
  }
282
315
  init() {
283
316
  _SimpleBar.instances.set(this.el, this);
284
- if (canUseDOM) {
317
+ if (canUseDOM$1) {
285
318
  this.initDOM();
286
319
  this.setAccessibilityAttributes();
287
320
  this.scrollbarWidth = this.getScrollbarWidth();
@@ -456,6 +489,9 @@ const _SimpleBar = class {
456
489
  this.toggleTrackVisibility("x");
457
490
  this.toggleTrackVisibility("y");
458
491
  }
492
+ /**
493
+ * Calculate scrollbar size
494
+ */
459
495
  getScrollbarSize(axis = "y") {
460
496
  if (!this.axis[axis].isOverflowing) {
461
497
  return 0;
@@ -530,6 +566,9 @@ const _SimpleBar = class {
530
566
  this.axis[axis].track.el.classList.remove(this.classNames.hover);
531
567
  this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
532
568
  }
569
+ /**
570
+ * Show scrollbar
571
+ */
533
572
  showScrollbar(axis = "y") {
534
573
  let scrollbar = this.axis[axis].scrollbar.el;
535
574
  if (!this.axis[axis].isVisible) {
@@ -540,6 +579,9 @@ const _SimpleBar = class {
540
579
  this.hideScrollbars();
541
580
  }
542
581
  }
582
+ /**
583
+ * on scrollbar handle drag movement starts
584
+ */
543
585
  onDragStart(e, axis = "y") {
544
586
  const elDocument = getElementDocument(this.el);
545
587
  const elWindow = getElementWindow(this.el);
@@ -591,9 +633,15 @@ const _SimpleBar = class {
591
633
  };
592
634
  scrollTo();
593
635
  }
636
+ /**
637
+ * Getter for content element
638
+ */
594
639
  getContentElement() {
595
640
  return this.contentEl;
596
641
  }
642
+ /**
643
+ * Getter for original scrolling element
644
+ */
597
645
  getScrollElement() {
598
646
  return this.contentWrapperEl;
599
647
  }
@@ -639,13 +687,22 @@ const _SimpleBar = class {
639
687
  this.hideScrollbars.cancel();
640
688
  this.onWindowResize.cancel();
641
689
  }
690
+ /**
691
+ * UnMount mutation observer and delete SimpleBar instance from DOM element
692
+ */
642
693
  unMount() {
643
694
  this.removeListeners();
644
695
  _SimpleBar.instances.delete(this.el);
645
696
  }
697
+ /**
698
+ * Check if mouse is within bounds
699
+ */
646
700
  isWithinBounds(bbox) {
647
701
  return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
648
702
  }
703
+ /**
704
+ * Find element children matches query
705
+ */
649
706
  findChild(el, query) {
650
707
  const matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
651
708
  return Array.prototype.filter.call(
@@ -1,9 +1,10 @@
1
- import throttle from 'lodash/throttle';
2
- import debounce from 'lodash/debounce';
3
- import memoize from 'lodash/memoize';
1
+ import throttle from 'lodash/throttle.js';
2
+ import debounce from 'lodash/debounce.js';
3
+ import memoize from 'lodash/memoize.js';
4
4
  import { ResizeObserver } from '@juggle/resize-observer';
5
5
 
6
6
  const canUseDOM = typeof window !== "undefined" && typeof window.document !== "undefined";
7
+ const canUseDOM$1 = canUseDOM;
7
8
 
8
9
  function getElementWindow(element) {
9
10
  if (!element || !element.ownerDocument || !element.ownerDocument.defaultView) {
@@ -20,7 +21,7 @@ function getElementDocument(element) {
20
21
 
21
22
  let cachedScrollbarWidth = null;
22
23
  let cachedDevicePixelRatio = null;
23
- if (canUseDOM) {
24
+ if (canUseDOM$1) {
24
25
  window.addEventListener("resize", () => {
25
26
  if (cachedDevicePixelRatio !== window.devicePixelRatio) {
26
27
  cachedDevicePixelRatio = window.devicePixelRatio;
@@ -54,6 +55,9 @@ var __publicField = (obj, key, value) => {
54
55
  };
55
56
  const _SimpleBar = class {
56
57
  constructor(element, options) {
58
+ /**
59
+ * On scroll event handling
60
+ */
57
61
  __publicField(this, "onScroll", () => {
58
62
  const elWindow = getElementWindow(this.el);
59
63
  if (!this.scrollXTicking) {
@@ -108,6 +112,9 @@ const _SimpleBar = class {
108
112
  this.scrollbarWidth = this.getScrollbarWidth();
109
113
  this.hideNativeScrollbar();
110
114
  });
115
+ /**
116
+ * Hide Scrollbar
117
+ */
111
118
  __publicField(this, "hideScrollbars", () => {
112
119
  this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
113
120
  this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
@@ -153,6 +160,9 @@ const _SimpleBar = class {
153
160
  }
154
161
  }
155
162
  });
163
+ /**
164
+ * Drag scrollbar handle
165
+ */
156
166
  __publicField(this, "drag", (e) => {
157
167
  let eventOffset;
158
168
  const track = this.axis[this.draggedAxis].track;
@@ -179,6 +189,9 @@ const _SimpleBar = class {
179
189
  }
180
190
  this.contentWrapperEl[this.axis[this.draggedAxis].scrollOffsetAttr] = scrollPos;
181
191
  });
192
+ /**
193
+ * End scroll handle drag
194
+ */
182
195
  __publicField(this, "onEndDrag", (e) => {
183
196
  const elDocument = getElementDocument(this.el);
184
197
  const elWindow = getElementWindow(this.el);
@@ -193,6 +206,9 @@ const _SimpleBar = class {
193
206
  this.removePreventClickId = null;
194
207
  });
195
208
  });
209
+ /**
210
+ * Handler to ignore click events during drag
211
+ */
196
212
  __publicField(this, "preventClick", (e) => {
197
213
  e.preventDefault();
198
214
  e.stopPropagation();
@@ -250,6 +266,15 @@ const _SimpleBar = class {
250
266
  _SimpleBar.getRtlHelpers = memoize(_SimpleBar.getRtlHelpers);
251
267
  this.init();
252
268
  }
269
+ /**
270
+ * Static properties
271
+ */
272
+ /**
273
+ * Helper to fix browsers inconsistency on RTL:
274
+ * - Firefox inverts the scrollbar initial position
275
+ * - IE11 inverts both scrollbar position and scrolling offset
276
+ * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
277
+ */
253
278
  static getRtlHelpers() {
254
279
  const dummyDiv = document.createElement("div");
255
280
  dummyDiv.innerHTML = '<div class="hs-dummy-scrollbar-size"><div style="height: 200%; width: 200%; margin: 10px 0;"></div></div>';
@@ -264,7 +289,9 @@ const _SimpleBar = class {
264
289
  dummyContainerChild
265
290
  );
266
291
  return {
292
+ // determines if the scrolling is responding with negative values
267
293
  isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
294
+ // determines if the origin scrollbar position is inverted or not (positioned on left or right)
268
295
  isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
269
296
  };
270
297
  }
@@ -279,7 +306,7 @@ const _SimpleBar = class {
279
306
  }
280
307
  init() {
281
308
  _SimpleBar.instances.set(this.el, this);
282
- if (canUseDOM) {
309
+ if (canUseDOM$1) {
283
310
  this.initDOM();
284
311
  this.setAccessibilityAttributes();
285
312
  this.scrollbarWidth = this.getScrollbarWidth();
@@ -454,6 +481,9 @@ const _SimpleBar = class {
454
481
  this.toggleTrackVisibility("x");
455
482
  this.toggleTrackVisibility("y");
456
483
  }
484
+ /**
485
+ * Calculate scrollbar size
486
+ */
457
487
  getScrollbarSize(axis = "y") {
458
488
  if (!this.axis[axis].isOverflowing) {
459
489
  return 0;
@@ -528,6 +558,9 @@ const _SimpleBar = class {
528
558
  this.axis[axis].track.el.classList.remove(this.classNames.hover);
529
559
  this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
530
560
  }
561
+ /**
562
+ * Show scrollbar
563
+ */
531
564
  showScrollbar(axis = "y") {
532
565
  let scrollbar = this.axis[axis].scrollbar.el;
533
566
  if (!this.axis[axis].isVisible) {
@@ -538,6 +571,9 @@ const _SimpleBar = class {
538
571
  this.hideScrollbars();
539
572
  }
540
573
  }
574
+ /**
575
+ * on scrollbar handle drag movement starts
576
+ */
541
577
  onDragStart(e, axis = "y") {
542
578
  const elDocument = getElementDocument(this.el);
543
579
  const elWindow = getElementWindow(this.el);
@@ -589,9 +625,15 @@ const _SimpleBar = class {
589
625
  };
590
626
  scrollTo();
591
627
  }
628
+ /**
629
+ * Getter for content element
630
+ */
592
631
  getContentElement() {
593
632
  return this.contentEl;
594
633
  }
634
+ /**
635
+ * Getter for original scrolling element
636
+ */
595
637
  getScrollElement() {
596
638
  return this.contentWrapperEl;
597
639
  }
@@ -637,13 +679,22 @@ const _SimpleBar = class {
637
679
  this.hideScrollbars.cancel();
638
680
  this.onWindowResize.cancel();
639
681
  }
682
+ /**
683
+ * UnMount mutation observer and delete SimpleBar instance from DOM element
684
+ */
640
685
  unMount() {
641
686
  this.removeListeners();
642
687
  _SimpleBar.instances.delete(this.el);
643
688
  }
689
+ /**
690
+ * Check if mouse is within bounds
691
+ */
644
692
  isWithinBounds(bbox) {
645
693
  return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
646
694
  }
695
+ /**
696
+ * Find element children matches query
697
+ */
647
698
  findChild(el, query) {
648
699
  const matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
649
700
  return Array.prototype.filter.call(
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@karta.io/simplebar",
3
- "version": "0.34.0-alpha.2",
3
+ "version": "0.34.0-alpha.4",
4
4
  "description": "Клон core части библиотеки simplebar",
5
+ "type": "module",
6
+ "sideEffects": false,
5
7
  "files": [
6
- "dist",
7
- "src",
8
- "README.md"
8
+ "dist"
9
9
  ],
10
10
  "author": "Vitaly Blokhin <karambafe@gmail.com>",
11
11
  "exports": {
@@ -24,7 +24,7 @@
24
24
  "lodash": "4.17.21"
25
25
  },
26
26
  "devDependencies": {
27
- "unbuild": "1.0.1"
27
+ "unbuild": "1.2.1"
28
28
  },
29
29
  "lint-staged": {
30
30
  "*.{js,jsx,json}": [
package/src/canUseDOM.js DELETED
@@ -1,3 +0,0 @@
1
- const canUseDOM = typeof window !== 'undefined' && typeof window.document !== 'undefined';
2
-
3
- export default canUseDOM;
package/src/helpers.js DELETED
@@ -1,46 +0,0 @@
1
- // Helper function to retrieve options from element attributes
2
- export const getOptions = function(obj) {
3
- const options = Array.prototype.reduce.call(
4
- obj,
5
- (acc, attribute) => {
6
- const option = attribute.name.match(/data-simplebar-(.+)/);
7
- if (option) {
8
- const key = option[1].replace(/\W+(.)/g, (x, chr) => chr.toUpperCase());
9
- switch (attribute.value) {
10
- case 'true':
11
- acc[key] = true;
12
- break;
13
- case 'false':
14
- acc[key] = false;
15
- break;
16
- case undefined:
17
- acc[key] = true;
18
- break;
19
- default:
20
- acc[key] = attribute.value;
21
- }
22
- }
23
- return acc;
24
- },
25
- {}
26
- );
27
- return options;
28
- };
29
-
30
- export function getElementWindow(element) {
31
- if (
32
- !element ||
33
- !element.ownerDocument ||
34
- !element.ownerDocument.defaultView
35
- ) {
36
- return window;
37
- }
38
- return element.ownerDocument.defaultView;
39
- }
40
-
41
- export function getElementDocument(element) {
42
- if (!element || !element.ownerDocument) {
43
- return document;
44
- }
45
- return element.ownerDocument;
46
- }
package/src/index.js DELETED
@@ -1,109 +0,0 @@
1
- import canUseDOM from './canUseDOM';
2
-
3
- import SimpleBar from './simplebar';
4
- import { getOptions } from './helpers';
5
-
6
- /**
7
- * @todo переписать на typescript
8
- */
9
- SimpleBar.initDOMLoadedElements = function() {
10
- document.removeEventListener('DOMContentLoaded', this.initDOMLoadedElements);
11
- window.removeEventListener('load', this.initDOMLoadedElements);
12
-
13
- Array.prototype.forEach.call(
14
- document.querySelectorAll('[data-simplebar]'),
15
- el => {
16
- if (
17
- el.getAttribute('data-simplebar') !== 'init' &&
18
- !SimpleBar.instances.has(el)
19
- )
20
- new SimpleBar(el, getOptions(el.attributes));
21
- }
22
- );
23
- };
24
-
25
- SimpleBar.removeObserver = function() {
26
- this.globalObserver.disconnect();
27
- };
28
-
29
- SimpleBar.initHtmlApi = function() {
30
- this.initDOMLoadedElements = this.initDOMLoadedElements.bind(this);
31
-
32
- // MutationObserver is IE11+
33
- if (typeof MutationObserver !== 'undefined') {
34
- // Mutation observer to observe dynamically added elements
35
- this.globalObserver = new MutationObserver(SimpleBar.handleMutations);
36
-
37
- this.globalObserver.observe(document, { childList: true, subtree: true });
38
- }
39
-
40
- // Taken from jQuery `ready` function
41
- // Instantiate elements already present on the page
42
- if (
43
- document.readyState === 'complete' ||
44
- (document.readyState !== 'loading' && !document.documentElement.doScroll)
45
- ) {
46
- // Handle it asynchronously to allow scripts the opportunity to delay init
47
- window.setTimeout(this.initDOMLoadedElements);
48
- } else {
49
- document.addEventListener('DOMContentLoaded', this.initDOMLoadedElements);
50
- window.addEventListener('load', this.initDOMLoadedElements);
51
- }
52
- };
53
-
54
- SimpleBar.handleMutations = mutations => {
55
- mutations.forEach(mutation => {
56
- Array.prototype.forEach.call(mutation.addedNodes, addedNode => {
57
- if (addedNode.nodeType === 1) {
58
- if (addedNode.hasAttribute('data-simplebar')) {
59
- !SimpleBar.instances.has(addedNode) &&
60
- document.documentElement.contains(addedNode) &&
61
- new SimpleBar(addedNode, getOptions(addedNode.attributes));
62
- } else {
63
- Array.prototype.forEach.call(
64
- addedNode.querySelectorAll('[data-simplebar]'),
65
- function(el) {
66
- if (
67
- el.getAttribute('data-simplebar') !== 'init' &&
68
- !SimpleBar.instances.has(el) &&
69
- document.documentElement.contains(el)
70
- )
71
- new SimpleBar(el, getOptions(el.attributes));
72
- }
73
- );
74
- }
75
- }
76
- });
77
-
78
- Array.prototype.forEach.call(mutation.removedNodes, removedNode => {
79
- if (removedNode.nodeType === 1) {
80
- if (removedNode.getAttribute('data-simplebar') === 'init') {
81
- SimpleBar.instances.has(removedNode) &&
82
- !document.documentElement.contains(removedNode) &&
83
- SimpleBar.instances.get(removedNode).unMount();
84
- } else {
85
- Array.prototype.forEach.call(
86
- removedNode.querySelectorAll('[data-simplebar="init"]'),
87
- el => {
88
- SimpleBar.instances.has(el) &&
89
- !document.documentElement.contains(el) &&
90
- SimpleBar.instances.get(el).unMount();
91
- }
92
- );
93
- }
94
- }
95
- });
96
- });
97
- };
98
-
99
- SimpleBar.getOptions = getOptions;
100
-
101
- /**
102
- * HTML API
103
- * Called only in a browser env.
104
- */
105
- if (canUseDOM) {
106
- SimpleBar.initHtmlApi();
107
- }
108
-
109
- export default SimpleBar;
@@ -1,40 +0,0 @@
1
- import canUseDOM from './canUseDOM';
2
- import { getElementDocument } from "./helpers";
3
-
4
- let cachedScrollbarWidth = null;
5
- let cachedDevicePixelRatio = null;
6
-
7
- if (canUseDOM) {
8
- window.addEventListener('resize', () => {
9
- if (cachedDevicePixelRatio !== window.devicePixelRatio) {
10
- cachedDevicePixelRatio = window.devicePixelRatio;
11
- cachedScrollbarWidth = null;
12
- }
13
- });
14
- }
15
-
16
- export default function scrollbarWidth(el) {
17
- if (cachedScrollbarWidth === null) {
18
-
19
- const document = getElementDocument(el);
20
-
21
- if (typeof document === 'undefined') {
22
- cachedScrollbarWidth = 0;
23
- return cachedScrollbarWidth;
24
- }
25
- const body = document.body;
26
- const box = document.createElement('div');
27
-
28
- box.classList.add('simplebar-hide-scrollbar');
29
-
30
- body.appendChild(box);
31
-
32
- const width = box.getBoundingClientRect().right;
33
-
34
- body.removeChild(box);
35
-
36
- cachedScrollbarWidth = width;
37
- }
38
-
39
- return cachedScrollbarWidth;
40
- }
@@ -1,51 +0,0 @@
1
- export as namespace SimpleBar;
2
- export = SimpleBar;
3
-
4
- declare namespace SimpleBar {
5
- interface KnownClassNamesOptions {
6
- contentEl?: string;
7
- contentWrapper?: string;
8
- offset?: string;
9
- mask?: string;
10
- wrapper?: string;
11
- placeholder?: string;
12
- scrollbar?: string;
13
- track?: string;
14
- heightAutoObserverWrapperEl?: string;
15
- heightAutoObserverEl?: string;
16
- visible?: string;
17
- horizontal?: string;
18
- vertical?: string;
19
- hover?: string;
20
- dragging?: string;
21
- }
22
-
23
- type ClassNamesOptions = KnownClassNamesOptions & {
24
- [className: string]: string;
25
- };
26
-
27
- interface Options {
28
- autoHide?: boolean;
29
- classNames?: ClassNamesOptions;
30
- forceVisible?: boolean | 'x' | 'y';
31
- direction?: 'rtl' | 'ltr';
32
- timeout?: number;
33
- clickOnTrack?: boolean;
34
- scrollbarMinSize?: number;
35
- scrollbarMaxSize?: number;
36
- }
37
- }
38
-
39
- declare class SimpleBar {
40
- static removeObserver(): void;
41
- static instances: Pick<WeakMap<HTMLElement, SimpleBar>, 'get' | 'has'>;
42
-
43
- constructor(element: HTMLElement, options?: SimpleBar.Options);
44
-
45
- recalculate(): void;
46
- getScrollElement(): HTMLElement;
47
- getContentElement(): HTMLElement;
48
- unMount(): void;
49
-
50
- el: HTMLElement;
51
- }