@karta.io/simplebar 1.0.0-beta.47 → 1.0.0-beta.49

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.
@@ -12,7 +12,6 @@ const debounce__default = /*#__PURE__*/_interopDefaultCompat(debounce);
12
12
  const memoize__default = /*#__PURE__*/_interopDefaultCompat(memoize);
13
13
 
14
14
  const canUseDOM = typeof window !== "undefined" && typeof window.document !== "undefined";
15
- const canUseDOM$1 = canUseDOM;
16
15
 
17
16
  function getElementWindow(element) {
18
17
  if (!element || !element.ownerDocument || !element.ownerDocument.defaultView) {
@@ -29,7 +28,7 @@ function getElementDocument(element) {
29
28
 
30
29
  let cachedScrollbarWidth = null;
31
30
  let cachedDevicePixelRatio = null;
32
- if (canUseDOM$1) {
31
+ if (canUseDOM) {
33
32
  window.addEventListener("resize", () => {
34
33
  if (cachedDevicePixelRatio !== window.devicePixelRatio) {
35
34
  cachedDevicePixelRatio = window.devicePixelRatio;
@@ -55,177 +54,13 @@ function scrollbarWidth(el) {
55
54
  return cachedScrollbarWidth;
56
55
  }
57
56
 
58
- var __defProp = Object.defineProperty;
59
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
60
- var __publicField = (obj, key, value) => {
61
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
62
- return value;
63
- };
64
- const _SimpleBar = class _SimpleBar {
57
+ class SimpleBar {
65
58
  constructor(element, options) {
66
- /**
67
- * On scroll event handling
68
- */
69
- __publicField(this, "onScroll", () => {
70
- const elWindow = getElementWindow(this.el);
71
- if (!this.scrollXTicking) {
72
- elWindow.requestAnimationFrame(this.scrollX);
73
- this.scrollXTicking = true;
74
- }
75
- if (!this.scrollYTicking) {
76
- elWindow.requestAnimationFrame(this.scrollY);
77
- this.scrollYTicking = true;
78
- }
79
- });
80
- __publicField(this, "scrollX", () => {
81
- if (this.axis.x.isOverflowing) {
82
- this.showScrollbar("x");
83
- this.positionScrollbar("x");
84
- }
85
- this.scrollXTicking = false;
86
- });
87
- __publicField(this, "scrollY", () => {
88
- if (this.axis.y.isOverflowing) {
89
- this.showScrollbar("y");
90
- this.positionScrollbar("y");
91
- }
92
- this.scrollYTicking = false;
93
- });
94
- __publicField(this, "onMouseEnter", () => {
95
- this.showScrollbar("x");
96
- this.showScrollbar("y");
97
- });
98
- __publicField(this, "onMouseMove", (e) => {
99
- this.mouseX = e.clientX;
100
- this.mouseY = e.clientY;
101
- if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
102
- this.onMouseMoveForAxis("x");
103
- }
104
- if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
105
- this.onMouseMoveForAxis("y");
106
- }
107
- });
108
- __publicField(this, "onMouseLeave", () => {
109
- this.onMouseMove.cancel();
110
- if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
111
- this.onMouseLeaveForAxis("x");
112
- }
113
- if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
114
- this.onMouseLeaveForAxis("y");
115
- }
116
- this.mouseX = -1;
117
- this.mouseY = -1;
118
- });
119
- __publicField(this, "onWindowResize", () => {
120
- this.scrollbarWidth = this.getScrollbarWidth();
121
- this.hideNativeScrollbar();
122
- });
123
- /**
124
- * Hide Scrollbar
125
- */
126
- __publicField(this, "hideScrollbars", () => {
127
- this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
128
- this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
129
- if (!this.isWithinBounds(this.axis.y.track.rect)) {
130
- this.axis.y.scrollbar.el.classList.remove(this.classNames.visible);
131
- this.axis.y.isVisible = false;
132
- }
133
- if (!this.isWithinBounds(this.axis.x.track.rect)) {
134
- this.axis.x.scrollbar.el.classList.remove(this.classNames.visible);
135
- this.axis.x.isVisible = false;
136
- }
137
- });
138
- __publicField(this, "onPointerEvent", (e) => {
139
- let isWithinTrackXBounds, isWithinTrackYBounds;
140
- this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
141
- this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
142
- if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
143
- isWithinTrackXBounds = this.isWithinBounds(this.axis.x.track.rect);
144
- }
145
- if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
146
- isWithinTrackYBounds = this.isWithinBounds(this.axis.y.track.rect);
147
- }
148
- if (isWithinTrackXBounds || isWithinTrackYBounds) {
149
- e.preventDefault();
150
- e.stopPropagation();
151
- if (e.type === "mousedown") {
152
- if (isWithinTrackXBounds) {
153
- this.axis.x.scrollbar.rect = this.axis.x.scrollbar.el.getBoundingClientRect();
154
- if (this.isWithinBounds(this.axis.x.scrollbar.rect)) {
155
- this.onDragStart(e, "x");
156
- } else {
157
- this.onTrackClick(e, "x");
158
- }
159
- }
160
- if (isWithinTrackYBounds) {
161
- this.axis.y.scrollbar.rect = this.axis.y.scrollbar.el.getBoundingClientRect();
162
- if (this.isWithinBounds(this.axis.y.scrollbar.rect)) {
163
- this.onDragStart(e, "y");
164
- } else {
165
- this.onTrackClick(e, "y");
166
- }
167
- }
168
- }
169
- }
170
- });
171
- /**
172
- * Drag scrollbar handle
173
- */
174
- __publicField(this, "drag", (e) => {
175
- let eventOffset;
176
- const track = this.axis[this.draggedAxis].track;
177
- const trackSize = track.rect[this.axis[this.draggedAxis].sizeAttr];
178
- const scrollbar = this.axis[this.draggedAxis].scrollbar;
179
- const contentSize = this.contentWrapperEl[this.axis[this.draggedAxis].scrollSizeAttr];
180
- const hostSize = parseInt(
181
- this.elStyles[this.axis[this.draggedAxis].sizeAttr],
182
- 10
183
- );
184
- e.preventDefault();
185
- e.stopPropagation();
186
- if (this.draggedAxis === "y") {
187
- eventOffset = e.pageY;
188
- } else {
189
- eventOffset = e.pageX;
190
- }
191
- let dragPos = eventOffset - track.rect[this.axis[this.draggedAxis].offsetAttr] - this.axis[this.draggedAxis].dragOffset;
192
- let dragPerc = dragPos / (trackSize - scrollbar.size);
193
- let scrollPos = dragPerc * (contentSize - hostSize);
194
- if (this.draggedAxis === "x") {
195
- scrollPos = this.isRtl && _SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
196
- scrollPos = this.isRtl && _SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
197
- }
198
- this.contentWrapperEl[this.axis[this.draggedAxis].scrollOffsetAttr] = scrollPos;
199
- });
200
- /**
201
- * End scroll handle drag
202
- */
203
- __publicField(this, "onEndDrag", (e) => {
204
- const elDocument = getElementDocument(this.el);
205
- const elWindow = getElementWindow(this.el);
206
- e.preventDefault();
207
- e.stopPropagation();
208
- this.el.classList.remove(this.classNames.dragging);
209
- elDocument.removeEventListener("mousemove", this.drag, true);
210
- elDocument.removeEventListener("mouseup", this.onEndDrag, true);
211
- this.removePreventClickId = elWindow.setTimeout(() => {
212
- elDocument.removeEventListener("click", this.preventClick, true);
213
- elDocument.removeEventListener("dblclick", this.preventClick, true);
214
- this.removePreventClickId = null;
215
- });
216
- });
217
- /**
218
- * Handler to ignore click events during drag
219
- */
220
- __publicField(this, "preventClick", (e) => {
221
- e.preventDefault();
222
- e.stopPropagation();
223
- });
224
59
  this.el = element;
225
60
  this.minScrollbarWidth = 20;
226
- this.options = { ..._SimpleBar.defaultOptions, ...options };
61
+ this.options = { ...SimpleBar.defaultOptions, ...options };
227
62
  this.classNames = {
228
- ..._SimpleBar.defaultOptions.classNames,
63
+ ...SimpleBar.defaultOptions.classNames,
229
64
  ...this.options.classNames
230
65
  };
231
66
  this.axis = {
@@ -259,7 +94,7 @@ const _SimpleBar = class _SimpleBar {
259
94
  }
260
95
  };
261
96
  this.removePreventClickId = null;
262
- if (_SimpleBar.instances.has(this.el)) {
97
+ if (SimpleBar.instances.has(this.el)) {
263
98
  return;
264
99
  }
265
100
  this.recalculate = throttle__default(this.recalculate.bind(this), 64);
@@ -271,7 +106,7 @@ const _SimpleBar = class _SimpleBar {
271
106
  this.onWindowResize = debounce__default(this.onWindowResize.bind(this), 64, {
272
107
  leading: true
273
108
  });
274
- _SimpleBar.getRtlHelpers = memoize__default(_SimpleBar.getRtlHelpers);
109
+ SimpleBar.getRtlHelpers = memoize__default(SimpleBar.getRtlHelpers);
275
110
  this.init();
276
111
  }
277
112
  /**
@@ -290,10 +125,10 @@ const _SimpleBar = class _SimpleBar {
290
125
  document.body.appendChild(scrollbarDummyEl);
291
126
  const dummyContainerChild = scrollbarDummyEl.firstElementChild;
292
127
  scrollbarDummyEl.scrollLeft = 0;
293
- const dummyContainerOffset = _SimpleBar.getOffset(scrollbarDummyEl);
294
- const dummyContainerChildOffset = _SimpleBar.getOffset(dummyContainerChild);
128
+ const dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
129
+ const dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
295
130
  scrollbarDummyEl.scrollLeft = 999;
296
- const dummyContainerScrollOffsetAfterScroll = _SimpleBar.getOffset(
131
+ const dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(
297
132
  dummyContainerChild
298
133
  );
299
134
  return {
@@ -303,6 +138,32 @@ const _SimpleBar = class _SimpleBar {
303
138
  isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
304
139
  };
305
140
  }
141
+ static defaultOptions = {
142
+ autoHide: true,
143
+ forceVisible: false,
144
+ clickOnTrack: true,
145
+ clickOnTrackSpeed: 40,
146
+ classNames: {
147
+ contentEl: "simplebar-content",
148
+ contentWrapper: "simplebar-content-wrapper",
149
+ offset: "simplebar-offset",
150
+ mask: "simplebar-mask",
151
+ wrapper: "simplebar-wrapper",
152
+ placeholder: "simplebar-placeholder",
153
+ scrollbar: "simplebar-scrollbar",
154
+ track: "simplebar-track",
155
+ heightAutoObserverWrapperEl: "simplebar-height-auto-observer-wrapper",
156
+ heightAutoObserverEl: "simplebar-height-auto-observer",
157
+ visible: "simplebar-visible",
158
+ horizontal: "simplebar-horizontal",
159
+ vertical: "simplebar-vertical",
160
+ hover: "simplebar-hover",
161
+ dragging: "simplebar-dragging"
162
+ },
163
+ scrollbarMinSize: 25,
164
+ scrollbarMaxSize: 0,
165
+ timeout: 1e3
166
+ };
306
167
  static getOffset(el) {
307
168
  const rect = el.getBoundingClientRect();
308
169
  const elDocument = getElementDocument(el);
@@ -312,9 +173,10 @@ const _SimpleBar = class _SimpleBar {
312
173
  left: rect.left + (elWindow.pageXOffset || elDocument.documentElement.scrollLeft)
313
174
  };
314
175
  }
176
+ static instances = /* @__PURE__ */ new WeakMap();
315
177
  init() {
316
- _SimpleBar.instances.set(this.el, this);
317
- if (canUseDOM$1) {
178
+ SimpleBar.instances.set(this.el, this);
179
+ if (canUseDOM) {
318
180
  this.initDOM();
319
181
  this.setAccessibilityAttributes();
320
182
  this.scrollbarWidth = this.getScrollbarWidth();
@@ -435,8 +297,7 @@ const _SimpleBar = class _SimpleBar {
435
297
  let resizeObserverStarted = false;
436
298
  const resizeObserver$1 = elWindow.ResizeObserver || resizeObserver.ResizeObserver;
437
299
  this.resizeObserver = new resizeObserver$1(() => {
438
- if (!resizeObserverStarted)
439
- return;
300
+ if (!resizeObserverStarted) return;
440
301
  this.recalculate();
441
302
  });
442
303
  this.resizeObserver.observe(this.el);
@@ -518,10 +379,10 @@ const _SimpleBar = class _SimpleBar {
518
379
  const hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
519
380
  const scrollbar = this.axis[axis].scrollbar;
520
381
  let scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
521
- scrollOffset = axis === "x" && this.isRtl && _SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
382
+ scrollOffset = axis === "x" && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
522
383
  let scrollPourcent = scrollOffset / (contentSize - hostSize);
523
384
  let handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
524
- handleOffset = axis === "x" && this.isRtl && _SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
385
+ handleOffset = axis === "x" && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
525
386
  scrollbar.el.style.transform = axis === "x" ? `translate3d(${handleOffset}px, 0, 0)` : `translate3d(0, ${handleOffset}px, 0)`;
526
387
  }
527
388
  toggleTrackVisibility(axis = "y") {
@@ -544,6 +405,48 @@ const _SimpleBar = class _SimpleBar {
544
405
  this.offsetEl.style[this.isRtl ? "left" : "right"] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? `-${this.scrollbarWidth}px` : 0;
545
406
  this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? `-${this.scrollbarWidth}px` : 0;
546
407
  }
408
+ /**
409
+ * On scroll event handling
410
+ */
411
+ onScroll = () => {
412
+ const elWindow = getElementWindow(this.el);
413
+ if (!this.scrollXTicking) {
414
+ elWindow.requestAnimationFrame(this.scrollX);
415
+ this.scrollXTicking = true;
416
+ }
417
+ if (!this.scrollYTicking) {
418
+ elWindow.requestAnimationFrame(this.scrollY);
419
+ this.scrollYTicking = true;
420
+ }
421
+ };
422
+ scrollX = () => {
423
+ if (this.axis.x.isOverflowing) {
424
+ this.showScrollbar("x");
425
+ this.positionScrollbar("x");
426
+ }
427
+ this.scrollXTicking = false;
428
+ };
429
+ scrollY = () => {
430
+ if (this.axis.y.isOverflowing) {
431
+ this.showScrollbar("y");
432
+ this.positionScrollbar("y");
433
+ }
434
+ this.scrollYTicking = false;
435
+ };
436
+ onMouseEnter = () => {
437
+ this.showScrollbar("x");
438
+ this.showScrollbar("y");
439
+ };
440
+ onMouseMove = (e) => {
441
+ this.mouseX = e.clientX;
442
+ this.mouseY = e.clientY;
443
+ if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
444
+ this.onMouseMoveForAxis("x");
445
+ }
446
+ if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
447
+ this.onMouseMoveForAxis("y");
448
+ }
449
+ };
547
450
  onMouseMoveForAxis(axis = "y") {
548
451
  this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
549
452
  this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
@@ -562,10 +465,25 @@ const _SimpleBar = class _SimpleBar {
562
465
  this.axis[axis].track.el.classList.remove(this.classNames.hover);
563
466
  }
564
467
  }
468
+ onMouseLeave = () => {
469
+ this.onMouseMove.cancel();
470
+ if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
471
+ this.onMouseLeaveForAxis("x");
472
+ }
473
+ if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
474
+ this.onMouseLeaveForAxis("y");
475
+ }
476
+ this.mouseX = -1;
477
+ this.mouseY = -1;
478
+ };
565
479
  onMouseLeaveForAxis(axis = "y") {
566
480
  this.axis[axis].track.el.classList.remove(this.classNames.hover);
567
481
  this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
568
482
  }
483
+ onWindowResize = () => {
484
+ this.scrollbarWidth = this.getScrollbarWidth();
485
+ this.hideNativeScrollbar();
486
+ };
569
487
  /**
570
488
  * Show scrollbar
571
489
  */
@@ -579,6 +497,54 @@ const _SimpleBar = class _SimpleBar {
579
497
  this.hideScrollbars();
580
498
  }
581
499
  }
500
+ /**
501
+ * Hide Scrollbar
502
+ */
503
+ hideScrollbars = () => {
504
+ this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
505
+ this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
506
+ if (!this.isWithinBounds(this.axis.y.track.rect)) {
507
+ this.axis.y.scrollbar.el.classList.remove(this.classNames.visible);
508
+ this.axis.y.isVisible = false;
509
+ }
510
+ if (!this.isWithinBounds(this.axis.x.track.rect)) {
511
+ this.axis.x.scrollbar.el.classList.remove(this.classNames.visible);
512
+ this.axis.x.isVisible = false;
513
+ }
514
+ };
515
+ onPointerEvent = (e) => {
516
+ let isWithinTrackXBounds, isWithinTrackYBounds;
517
+ this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
518
+ this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
519
+ if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
520
+ isWithinTrackXBounds = this.isWithinBounds(this.axis.x.track.rect);
521
+ }
522
+ if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
523
+ isWithinTrackYBounds = this.isWithinBounds(this.axis.y.track.rect);
524
+ }
525
+ if (isWithinTrackXBounds || isWithinTrackYBounds) {
526
+ e.preventDefault();
527
+ e.stopPropagation();
528
+ if (e.type === "mousedown") {
529
+ if (isWithinTrackXBounds) {
530
+ this.axis.x.scrollbar.rect = this.axis.x.scrollbar.el.getBoundingClientRect();
531
+ if (this.isWithinBounds(this.axis.x.scrollbar.rect)) {
532
+ this.onDragStart(e, "x");
533
+ } else {
534
+ this.onTrackClick(e, "x");
535
+ }
536
+ }
537
+ if (isWithinTrackYBounds) {
538
+ this.axis.y.scrollbar.rect = this.axis.y.scrollbar.el.getBoundingClientRect();
539
+ if (this.isWithinBounds(this.axis.y.scrollbar.rect)) {
540
+ this.onDragStart(e, "y");
541
+ } else {
542
+ this.onTrackClick(e, "y");
543
+ }
544
+ }
545
+ }
546
+ }
547
+ };
582
548
  /**
583
549
  * on scrollbar handle drag movement starts
584
550
  */
@@ -600,9 +566,61 @@ const _SimpleBar = class _SimpleBar {
600
566
  this.removePreventClickId = null;
601
567
  }
602
568
  }
569
+ /**
570
+ * Drag scrollbar handle
571
+ */
572
+ drag = (e) => {
573
+ let eventOffset;
574
+ const track = this.axis[this.draggedAxis].track;
575
+ const trackSize = track.rect[this.axis[this.draggedAxis].sizeAttr];
576
+ const scrollbar = this.axis[this.draggedAxis].scrollbar;
577
+ const contentSize = this.contentWrapperEl[this.axis[this.draggedAxis].scrollSizeAttr];
578
+ const hostSize = parseInt(
579
+ this.elStyles[this.axis[this.draggedAxis].sizeAttr],
580
+ 10
581
+ );
582
+ e.preventDefault();
583
+ e.stopPropagation();
584
+ if (this.draggedAxis === "y") {
585
+ eventOffset = e.pageY;
586
+ } else {
587
+ eventOffset = e.pageX;
588
+ }
589
+ let dragPos = eventOffset - track.rect[this.axis[this.draggedAxis].offsetAttr] - this.axis[this.draggedAxis].dragOffset;
590
+ let dragPerc = dragPos / (trackSize - scrollbar.size);
591
+ let scrollPos = dragPerc * (contentSize - hostSize);
592
+ if (this.draggedAxis === "x") {
593
+ scrollPos = this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
594
+ scrollPos = this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
595
+ }
596
+ this.contentWrapperEl[this.axis[this.draggedAxis].scrollOffsetAttr] = scrollPos;
597
+ };
598
+ /**
599
+ * End scroll handle drag
600
+ */
601
+ onEndDrag = (e) => {
602
+ const elDocument = getElementDocument(this.el);
603
+ const elWindow = getElementWindow(this.el);
604
+ e.preventDefault();
605
+ e.stopPropagation();
606
+ this.el.classList.remove(this.classNames.dragging);
607
+ elDocument.removeEventListener("mousemove", this.drag, true);
608
+ elDocument.removeEventListener("mouseup", this.onEndDrag, true);
609
+ this.removePreventClickId = elWindow.setTimeout(() => {
610
+ elDocument.removeEventListener("click", this.preventClick, true);
611
+ elDocument.removeEventListener("dblclick", this.preventClick, true);
612
+ this.removePreventClickId = null;
613
+ });
614
+ };
615
+ /**
616
+ * Handler to ignore click events during drag
617
+ */
618
+ preventClick = (e) => {
619
+ e.preventDefault();
620
+ e.stopPropagation();
621
+ };
603
622
  onTrackClick(e, axis = "y") {
604
- if (!this.options.clickOnTrack)
605
- return;
623
+ if (!this.options.clickOnTrack) return;
606
624
  const elWindow = getElementWindow(this.el);
607
625
  this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
608
626
  const scrollbar = this.axis[axis].scrollbar;
@@ -692,7 +710,7 @@ const _SimpleBar = class _SimpleBar {
692
710
  */
693
711
  unMount() {
694
712
  this.removeListeners();
695
- _SimpleBar.instances.delete(this.el);
713
+ SimpleBar.instances.delete(this.el);
696
714
  }
697
715
  /**
698
716
  * Check if mouse is within bounds
@@ -710,34 +728,6 @@ const _SimpleBar = class _SimpleBar {
710
728
  (child) => matches.call(child, query)
711
729
  )[0];
712
730
  }
713
- };
714
- __publicField(_SimpleBar, "defaultOptions", {
715
- autoHide: true,
716
- forceVisible: false,
717
- clickOnTrack: true,
718
- clickOnTrackSpeed: 40,
719
- classNames: {
720
- contentEl: "simplebar-content",
721
- contentWrapper: "simplebar-content-wrapper",
722
- offset: "simplebar-offset",
723
- mask: "simplebar-mask",
724
- wrapper: "simplebar-wrapper",
725
- placeholder: "simplebar-placeholder",
726
- scrollbar: "simplebar-scrollbar",
727
- track: "simplebar-track",
728
- heightAutoObserverWrapperEl: "simplebar-height-auto-observer-wrapper",
729
- heightAutoObserverEl: "simplebar-height-auto-observer",
730
- visible: "simplebar-visible",
731
- horizontal: "simplebar-horizontal",
732
- vertical: "simplebar-vertical",
733
- hover: "simplebar-hover",
734
- dragging: "simplebar-dragging"
735
- },
736
- scrollbarMinSize: 25,
737
- scrollbarMaxSize: 0,
738
- timeout: 1e3
739
- });
740
- __publicField(_SimpleBar, "instances", /* @__PURE__ */ new WeakMap());
741
- let SimpleBar = _SimpleBar;
731
+ }
742
732
 
743
733
  module.exports = SimpleBar;
@@ -47,4 +47,4 @@ declare class SimpleBar {
47
47
  el: HTMLElement;
48
48
  }
49
49
 
50
- export { SimpleBar as default };
50
+ export = SimpleBar;
@@ -47,4 +47,4 @@ declare class SimpleBar {
47
47
  el: HTMLElement;
48
48
  }
49
49
 
50
- export { SimpleBar as default };
50
+ export = SimpleBar;
@@ -4,7 +4,6 @@ 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;
8
7
 
9
8
  function getElementWindow(element) {
10
9
  if (!element || !element.ownerDocument || !element.ownerDocument.defaultView) {
@@ -21,7 +20,7 @@ function getElementDocument(element) {
21
20
 
22
21
  let cachedScrollbarWidth = null;
23
22
  let cachedDevicePixelRatio = null;
24
- if (canUseDOM$1) {
23
+ if (canUseDOM) {
25
24
  window.addEventListener("resize", () => {
26
25
  if (cachedDevicePixelRatio !== window.devicePixelRatio) {
27
26
  cachedDevicePixelRatio = window.devicePixelRatio;
@@ -47,177 +46,13 @@ function scrollbarWidth(el) {
47
46
  return cachedScrollbarWidth;
48
47
  }
49
48
 
50
- var __defProp = Object.defineProperty;
51
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
52
- var __publicField = (obj, key, value) => {
53
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
54
- return value;
55
- };
56
- const _SimpleBar = class _SimpleBar {
49
+ class SimpleBar {
57
50
  constructor(element, options) {
58
- /**
59
- * On scroll event handling
60
- */
61
- __publicField(this, "onScroll", () => {
62
- const elWindow = getElementWindow(this.el);
63
- if (!this.scrollXTicking) {
64
- elWindow.requestAnimationFrame(this.scrollX);
65
- this.scrollXTicking = true;
66
- }
67
- if (!this.scrollYTicking) {
68
- elWindow.requestAnimationFrame(this.scrollY);
69
- this.scrollYTicking = true;
70
- }
71
- });
72
- __publicField(this, "scrollX", () => {
73
- if (this.axis.x.isOverflowing) {
74
- this.showScrollbar("x");
75
- this.positionScrollbar("x");
76
- }
77
- this.scrollXTicking = false;
78
- });
79
- __publicField(this, "scrollY", () => {
80
- if (this.axis.y.isOverflowing) {
81
- this.showScrollbar("y");
82
- this.positionScrollbar("y");
83
- }
84
- this.scrollYTicking = false;
85
- });
86
- __publicField(this, "onMouseEnter", () => {
87
- this.showScrollbar("x");
88
- this.showScrollbar("y");
89
- });
90
- __publicField(this, "onMouseMove", (e) => {
91
- this.mouseX = e.clientX;
92
- this.mouseY = e.clientY;
93
- if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
94
- this.onMouseMoveForAxis("x");
95
- }
96
- if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
97
- this.onMouseMoveForAxis("y");
98
- }
99
- });
100
- __publicField(this, "onMouseLeave", () => {
101
- this.onMouseMove.cancel();
102
- if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
103
- this.onMouseLeaveForAxis("x");
104
- }
105
- if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
106
- this.onMouseLeaveForAxis("y");
107
- }
108
- this.mouseX = -1;
109
- this.mouseY = -1;
110
- });
111
- __publicField(this, "onWindowResize", () => {
112
- this.scrollbarWidth = this.getScrollbarWidth();
113
- this.hideNativeScrollbar();
114
- });
115
- /**
116
- * Hide Scrollbar
117
- */
118
- __publicField(this, "hideScrollbars", () => {
119
- this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
120
- this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
121
- if (!this.isWithinBounds(this.axis.y.track.rect)) {
122
- this.axis.y.scrollbar.el.classList.remove(this.classNames.visible);
123
- this.axis.y.isVisible = false;
124
- }
125
- if (!this.isWithinBounds(this.axis.x.track.rect)) {
126
- this.axis.x.scrollbar.el.classList.remove(this.classNames.visible);
127
- this.axis.x.isVisible = false;
128
- }
129
- });
130
- __publicField(this, "onPointerEvent", (e) => {
131
- let isWithinTrackXBounds, isWithinTrackYBounds;
132
- this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
133
- this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
134
- if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
135
- isWithinTrackXBounds = this.isWithinBounds(this.axis.x.track.rect);
136
- }
137
- if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
138
- isWithinTrackYBounds = this.isWithinBounds(this.axis.y.track.rect);
139
- }
140
- if (isWithinTrackXBounds || isWithinTrackYBounds) {
141
- e.preventDefault();
142
- e.stopPropagation();
143
- if (e.type === "mousedown") {
144
- if (isWithinTrackXBounds) {
145
- this.axis.x.scrollbar.rect = this.axis.x.scrollbar.el.getBoundingClientRect();
146
- if (this.isWithinBounds(this.axis.x.scrollbar.rect)) {
147
- this.onDragStart(e, "x");
148
- } else {
149
- this.onTrackClick(e, "x");
150
- }
151
- }
152
- if (isWithinTrackYBounds) {
153
- this.axis.y.scrollbar.rect = this.axis.y.scrollbar.el.getBoundingClientRect();
154
- if (this.isWithinBounds(this.axis.y.scrollbar.rect)) {
155
- this.onDragStart(e, "y");
156
- } else {
157
- this.onTrackClick(e, "y");
158
- }
159
- }
160
- }
161
- }
162
- });
163
- /**
164
- * Drag scrollbar handle
165
- */
166
- __publicField(this, "drag", (e) => {
167
- let eventOffset;
168
- const track = this.axis[this.draggedAxis].track;
169
- const trackSize = track.rect[this.axis[this.draggedAxis].sizeAttr];
170
- const scrollbar = this.axis[this.draggedAxis].scrollbar;
171
- const contentSize = this.contentWrapperEl[this.axis[this.draggedAxis].scrollSizeAttr];
172
- const hostSize = parseInt(
173
- this.elStyles[this.axis[this.draggedAxis].sizeAttr],
174
- 10
175
- );
176
- e.preventDefault();
177
- e.stopPropagation();
178
- if (this.draggedAxis === "y") {
179
- eventOffset = e.pageY;
180
- } else {
181
- eventOffset = e.pageX;
182
- }
183
- let dragPos = eventOffset - track.rect[this.axis[this.draggedAxis].offsetAttr] - this.axis[this.draggedAxis].dragOffset;
184
- let dragPerc = dragPos / (trackSize - scrollbar.size);
185
- let scrollPos = dragPerc * (contentSize - hostSize);
186
- if (this.draggedAxis === "x") {
187
- scrollPos = this.isRtl && _SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
188
- scrollPos = this.isRtl && _SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
189
- }
190
- this.contentWrapperEl[this.axis[this.draggedAxis].scrollOffsetAttr] = scrollPos;
191
- });
192
- /**
193
- * End scroll handle drag
194
- */
195
- __publicField(this, "onEndDrag", (e) => {
196
- const elDocument = getElementDocument(this.el);
197
- const elWindow = getElementWindow(this.el);
198
- e.preventDefault();
199
- e.stopPropagation();
200
- this.el.classList.remove(this.classNames.dragging);
201
- elDocument.removeEventListener("mousemove", this.drag, true);
202
- elDocument.removeEventListener("mouseup", this.onEndDrag, true);
203
- this.removePreventClickId = elWindow.setTimeout(() => {
204
- elDocument.removeEventListener("click", this.preventClick, true);
205
- elDocument.removeEventListener("dblclick", this.preventClick, true);
206
- this.removePreventClickId = null;
207
- });
208
- });
209
- /**
210
- * Handler to ignore click events during drag
211
- */
212
- __publicField(this, "preventClick", (e) => {
213
- e.preventDefault();
214
- e.stopPropagation();
215
- });
216
51
  this.el = element;
217
52
  this.minScrollbarWidth = 20;
218
- this.options = { ..._SimpleBar.defaultOptions, ...options };
53
+ this.options = { ...SimpleBar.defaultOptions, ...options };
219
54
  this.classNames = {
220
- ..._SimpleBar.defaultOptions.classNames,
55
+ ...SimpleBar.defaultOptions.classNames,
221
56
  ...this.options.classNames
222
57
  };
223
58
  this.axis = {
@@ -251,7 +86,7 @@ const _SimpleBar = class _SimpleBar {
251
86
  }
252
87
  };
253
88
  this.removePreventClickId = null;
254
- if (_SimpleBar.instances.has(this.el)) {
89
+ if (SimpleBar.instances.has(this.el)) {
255
90
  return;
256
91
  }
257
92
  this.recalculate = throttle(this.recalculate.bind(this), 64);
@@ -263,7 +98,7 @@ const _SimpleBar = class _SimpleBar {
263
98
  this.onWindowResize = debounce(this.onWindowResize.bind(this), 64, {
264
99
  leading: true
265
100
  });
266
- _SimpleBar.getRtlHelpers = memoize(_SimpleBar.getRtlHelpers);
101
+ SimpleBar.getRtlHelpers = memoize(SimpleBar.getRtlHelpers);
267
102
  this.init();
268
103
  }
269
104
  /**
@@ -282,10 +117,10 @@ const _SimpleBar = class _SimpleBar {
282
117
  document.body.appendChild(scrollbarDummyEl);
283
118
  const dummyContainerChild = scrollbarDummyEl.firstElementChild;
284
119
  scrollbarDummyEl.scrollLeft = 0;
285
- const dummyContainerOffset = _SimpleBar.getOffset(scrollbarDummyEl);
286
- const dummyContainerChildOffset = _SimpleBar.getOffset(dummyContainerChild);
120
+ const dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
121
+ const dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
287
122
  scrollbarDummyEl.scrollLeft = 999;
288
- const dummyContainerScrollOffsetAfterScroll = _SimpleBar.getOffset(
123
+ const dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(
289
124
  dummyContainerChild
290
125
  );
291
126
  return {
@@ -295,6 +130,32 @@ const _SimpleBar = class _SimpleBar {
295
130
  isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
296
131
  };
297
132
  }
133
+ static defaultOptions = {
134
+ autoHide: true,
135
+ forceVisible: false,
136
+ clickOnTrack: true,
137
+ clickOnTrackSpeed: 40,
138
+ classNames: {
139
+ contentEl: "simplebar-content",
140
+ contentWrapper: "simplebar-content-wrapper",
141
+ offset: "simplebar-offset",
142
+ mask: "simplebar-mask",
143
+ wrapper: "simplebar-wrapper",
144
+ placeholder: "simplebar-placeholder",
145
+ scrollbar: "simplebar-scrollbar",
146
+ track: "simplebar-track",
147
+ heightAutoObserverWrapperEl: "simplebar-height-auto-observer-wrapper",
148
+ heightAutoObserverEl: "simplebar-height-auto-observer",
149
+ visible: "simplebar-visible",
150
+ horizontal: "simplebar-horizontal",
151
+ vertical: "simplebar-vertical",
152
+ hover: "simplebar-hover",
153
+ dragging: "simplebar-dragging"
154
+ },
155
+ scrollbarMinSize: 25,
156
+ scrollbarMaxSize: 0,
157
+ timeout: 1e3
158
+ };
298
159
  static getOffset(el) {
299
160
  const rect = el.getBoundingClientRect();
300
161
  const elDocument = getElementDocument(el);
@@ -304,9 +165,10 @@ const _SimpleBar = class _SimpleBar {
304
165
  left: rect.left + (elWindow.pageXOffset || elDocument.documentElement.scrollLeft)
305
166
  };
306
167
  }
168
+ static instances = /* @__PURE__ */ new WeakMap();
307
169
  init() {
308
- _SimpleBar.instances.set(this.el, this);
309
- if (canUseDOM$1) {
170
+ SimpleBar.instances.set(this.el, this);
171
+ if (canUseDOM) {
310
172
  this.initDOM();
311
173
  this.setAccessibilityAttributes();
312
174
  this.scrollbarWidth = this.getScrollbarWidth();
@@ -427,8 +289,7 @@ const _SimpleBar = class _SimpleBar {
427
289
  let resizeObserverStarted = false;
428
290
  const resizeObserver = elWindow.ResizeObserver || ResizeObserver;
429
291
  this.resizeObserver = new resizeObserver(() => {
430
- if (!resizeObserverStarted)
431
- return;
292
+ if (!resizeObserverStarted) return;
432
293
  this.recalculate();
433
294
  });
434
295
  this.resizeObserver.observe(this.el);
@@ -510,10 +371,10 @@ const _SimpleBar = class _SimpleBar {
510
371
  const hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
511
372
  const scrollbar = this.axis[axis].scrollbar;
512
373
  let scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
513
- scrollOffset = axis === "x" && this.isRtl && _SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
374
+ scrollOffset = axis === "x" && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
514
375
  let scrollPourcent = scrollOffset / (contentSize - hostSize);
515
376
  let handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
516
- handleOffset = axis === "x" && this.isRtl && _SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
377
+ handleOffset = axis === "x" && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
517
378
  scrollbar.el.style.transform = axis === "x" ? `translate3d(${handleOffset}px, 0, 0)` : `translate3d(0, ${handleOffset}px, 0)`;
518
379
  }
519
380
  toggleTrackVisibility(axis = "y") {
@@ -536,6 +397,48 @@ const _SimpleBar = class _SimpleBar {
536
397
  this.offsetEl.style[this.isRtl ? "left" : "right"] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? `-${this.scrollbarWidth}px` : 0;
537
398
  this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? `-${this.scrollbarWidth}px` : 0;
538
399
  }
400
+ /**
401
+ * On scroll event handling
402
+ */
403
+ onScroll = () => {
404
+ const elWindow = getElementWindow(this.el);
405
+ if (!this.scrollXTicking) {
406
+ elWindow.requestAnimationFrame(this.scrollX);
407
+ this.scrollXTicking = true;
408
+ }
409
+ if (!this.scrollYTicking) {
410
+ elWindow.requestAnimationFrame(this.scrollY);
411
+ this.scrollYTicking = true;
412
+ }
413
+ };
414
+ scrollX = () => {
415
+ if (this.axis.x.isOverflowing) {
416
+ this.showScrollbar("x");
417
+ this.positionScrollbar("x");
418
+ }
419
+ this.scrollXTicking = false;
420
+ };
421
+ scrollY = () => {
422
+ if (this.axis.y.isOverflowing) {
423
+ this.showScrollbar("y");
424
+ this.positionScrollbar("y");
425
+ }
426
+ this.scrollYTicking = false;
427
+ };
428
+ onMouseEnter = () => {
429
+ this.showScrollbar("x");
430
+ this.showScrollbar("y");
431
+ };
432
+ onMouseMove = (e) => {
433
+ this.mouseX = e.clientX;
434
+ this.mouseY = e.clientY;
435
+ if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
436
+ this.onMouseMoveForAxis("x");
437
+ }
438
+ if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
439
+ this.onMouseMoveForAxis("y");
440
+ }
441
+ };
539
442
  onMouseMoveForAxis(axis = "y") {
540
443
  this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
541
444
  this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
@@ -554,10 +457,25 @@ const _SimpleBar = class _SimpleBar {
554
457
  this.axis[axis].track.el.classList.remove(this.classNames.hover);
555
458
  }
556
459
  }
460
+ onMouseLeave = () => {
461
+ this.onMouseMove.cancel();
462
+ if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
463
+ this.onMouseLeaveForAxis("x");
464
+ }
465
+ if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
466
+ this.onMouseLeaveForAxis("y");
467
+ }
468
+ this.mouseX = -1;
469
+ this.mouseY = -1;
470
+ };
557
471
  onMouseLeaveForAxis(axis = "y") {
558
472
  this.axis[axis].track.el.classList.remove(this.classNames.hover);
559
473
  this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
560
474
  }
475
+ onWindowResize = () => {
476
+ this.scrollbarWidth = this.getScrollbarWidth();
477
+ this.hideNativeScrollbar();
478
+ };
561
479
  /**
562
480
  * Show scrollbar
563
481
  */
@@ -571,6 +489,54 @@ const _SimpleBar = class _SimpleBar {
571
489
  this.hideScrollbars();
572
490
  }
573
491
  }
492
+ /**
493
+ * Hide Scrollbar
494
+ */
495
+ hideScrollbars = () => {
496
+ this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
497
+ this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
498
+ if (!this.isWithinBounds(this.axis.y.track.rect)) {
499
+ this.axis.y.scrollbar.el.classList.remove(this.classNames.visible);
500
+ this.axis.y.isVisible = false;
501
+ }
502
+ if (!this.isWithinBounds(this.axis.x.track.rect)) {
503
+ this.axis.x.scrollbar.el.classList.remove(this.classNames.visible);
504
+ this.axis.x.isVisible = false;
505
+ }
506
+ };
507
+ onPointerEvent = (e) => {
508
+ let isWithinTrackXBounds, isWithinTrackYBounds;
509
+ this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
510
+ this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
511
+ if (this.axis.x.isOverflowing || this.axis.x.forceVisible) {
512
+ isWithinTrackXBounds = this.isWithinBounds(this.axis.x.track.rect);
513
+ }
514
+ if (this.axis.y.isOverflowing || this.axis.y.forceVisible) {
515
+ isWithinTrackYBounds = this.isWithinBounds(this.axis.y.track.rect);
516
+ }
517
+ if (isWithinTrackXBounds || isWithinTrackYBounds) {
518
+ e.preventDefault();
519
+ e.stopPropagation();
520
+ if (e.type === "mousedown") {
521
+ if (isWithinTrackXBounds) {
522
+ this.axis.x.scrollbar.rect = this.axis.x.scrollbar.el.getBoundingClientRect();
523
+ if (this.isWithinBounds(this.axis.x.scrollbar.rect)) {
524
+ this.onDragStart(e, "x");
525
+ } else {
526
+ this.onTrackClick(e, "x");
527
+ }
528
+ }
529
+ if (isWithinTrackYBounds) {
530
+ this.axis.y.scrollbar.rect = this.axis.y.scrollbar.el.getBoundingClientRect();
531
+ if (this.isWithinBounds(this.axis.y.scrollbar.rect)) {
532
+ this.onDragStart(e, "y");
533
+ } else {
534
+ this.onTrackClick(e, "y");
535
+ }
536
+ }
537
+ }
538
+ }
539
+ };
574
540
  /**
575
541
  * on scrollbar handle drag movement starts
576
542
  */
@@ -592,9 +558,61 @@ const _SimpleBar = class _SimpleBar {
592
558
  this.removePreventClickId = null;
593
559
  }
594
560
  }
561
+ /**
562
+ * Drag scrollbar handle
563
+ */
564
+ drag = (e) => {
565
+ let eventOffset;
566
+ const track = this.axis[this.draggedAxis].track;
567
+ const trackSize = track.rect[this.axis[this.draggedAxis].sizeAttr];
568
+ const scrollbar = this.axis[this.draggedAxis].scrollbar;
569
+ const contentSize = this.contentWrapperEl[this.axis[this.draggedAxis].scrollSizeAttr];
570
+ const hostSize = parseInt(
571
+ this.elStyles[this.axis[this.draggedAxis].sizeAttr],
572
+ 10
573
+ );
574
+ e.preventDefault();
575
+ e.stopPropagation();
576
+ if (this.draggedAxis === "y") {
577
+ eventOffset = e.pageY;
578
+ } else {
579
+ eventOffset = e.pageX;
580
+ }
581
+ let dragPos = eventOffset - track.rect[this.axis[this.draggedAxis].offsetAttr] - this.axis[this.draggedAxis].dragOffset;
582
+ let dragPerc = dragPos / (trackSize - scrollbar.size);
583
+ let scrollPos = dragPerc * (contentSize - hostSize);
584
+ if (this.draggedAxis === "x") {
585
+ scrollPos = this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
586
+ scrollPos = this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
587
+ }
588
+ this.contentWrapperEl[this.axis[this.draggedAxis].scrollOffsetAttr] = scrollPos;
589
+ };
590
+ /**
591
+ * End scroll handle drag
592
+ */
593
+ onEndDrag = (e) => {
594
+ const elDocument = getElementDocument(this.el);
595
+ const elWindow = getElementWindow(this.el);
596
+ e.preventDefault();
597
+ e.stopPropagation();
598
+ this.el.classList.remove(this.classNames.dragging);
599
+ elDocument.removeEventListener("mousemove", this.drag, true);
600
+ elDocument.removeEventListener("mouseup", this.onEndDrag, true);
601
+ this.removePreventClickId = elWindow.setTimeout(() => {
602
+ elDocument.removeEventListener("click", this.preventClick, true);
603
+ elDocument.removeEventListener("dblclick", this.preventClick, true);
604
+ this.removePreventClickId = null;
605
+ });
606
+ };
607
+ /**
608
+ * Handler to ignore click events during drag
609
+ */
610
+ preventClick = (e) => {
611
+ e.preventDefault();
612
+ e.stopPropagation();
613
+ };
595
614
  onTrackClick(e, axis = "y") {
596
- if (!this.options.clickOnTrack)
597
- return;
615
+ if (!this.options.clickOnTrack) return;
598
616
  const elWindow = getElementWindow(this.el);
599
617
  this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
600
618
  const scrollbar = this.axis[axis].scrollbar;
@@ -684,7 +702,7 @@ const _SimpleBar = class _SimpleBar {
684
702
  */
685
703
  unMount() {
686
704
  this.removeListeners();
687
- _SimpleBar.instances.delete(this.el);
705
+ SimpleBar.instances.delete(this.el);
688
706
  }
689
707
  /**
690
708
  * Check if mouse is within bounds
@@ -702,34 +720,6 @@ const _SimpleBar = class _SimpleBar {
702
720
  (child) => matches.call(child, query)
703
721
  )[0];
704
722
  }
705
- };
706
- __publicField(_SimpleBar, "defaultOptions", {
707
- autoHide: true,
708
- forceVisible: false,
709
- clickOnTrack: true,
710
- clickOnTrackSpeed: 40,
711
- classNames: {
712
- contentEl: "simplebar-content",
713
- contentWrapper: "simplebar-content-wrapper",
714
- offset: "simplebar-offset",
715
- mask: "simplebar-mask",
716
- wrapper: "simplebar-wrapper",
717
- placeholder: "simplebar-placeholder",
718
- scrollbar: "simplebar-scrollbar",
719
- track: "simplebar-track",
720
- heightAutoObserverWrapperEl: "simplebar-height-auto-observer-wrapper",
721
- heightAutoObserverEl: "simplebar-height-auto-observer",
722
- visible: "simplebar-visible",
723
- horizontal: "simplebar-horizontal",
724
- vertical: "simplebar-vertical",
725
- hover: "simplebar-hover",
726
- dragging: "simplebar-dragging"
727
- },
728
- scrollbarMinSize: 25,
729
- scrollbarMaxSize: 0,
730
- timeout: 1e3
731
- });
732
- __publicField(_SimpleBar, "instances", /* @__PURE__ */ new WeakMap());
733
- let SimpleBar = _SimpleBar;
723
+ }
734
724
 
735
725
  export { SimpleBar as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karta.io/simplebar",
3
- "version": "1.0.0-beta.47",
3
+ "version": "1.0.0-beta.49",
4
4
  "description": "Клон core части библиотеки simplebar",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -21,10 +21,10 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@juggle/resize-observer": "3.4.0",
24
- "lodash": "4.17.21"
24
+ "lodash": "4.17.23"
25
25
  },
26
26
  "devDependencies": {
27
- "unbuild": "2.0.0"
27
+ "unbuild": "3.6.1"
28
28
  },
29
29
  "lint-staged": {
30
30
  "*.{js,jsx,json}": [