@karta.io/simplebar 0.20.4 → 0.21.0

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.
@@ -4,10 +4,6 @@ const lodashEs = require('lodash-es');
4
4
  const resizeObserver = require('@juggle/resize-observer');
5
5
  const canUseDOM = require('can-use-dom');
6
6
 
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
8
-
9
- const canUseDOM__default = /*#__PURE__*/_interopDefaultLegacy(canUseDOM);
10
-
11
7
  function getElementWindow(element) {
12
8
  if (!element || !element.ownerDocument || !element.ownerDocument.defaultView) {
13
9
  return window;
@@ -23,7 +19,7 @@ function getElementDocument(element) {
23
19
 
24
20
  let cachedScrollbarWidth = null;
25
21
  let cachedDevicePixelRatio = null;
26
- if (canUseDOM__default) {
22
+ if (canUseDOM) {
27
23
  window.addEventListener("resize", () => {
28
24
  if (cachedDevicePixelRatio !== window.devicePixelRatio) {
29
25
  cachedDevicePixelRatio = window.devicePixelRatio;
@@ -162,7 +158,10 @@ const _SimpleBar = class {
162
158
  const trackSize = track.rect[this.axis[this.draggedAxis].sizeAttr];
163
159
  const scrollbar = this.axis[this.draggedAxis].scrollbar;
164
160
  const contentSize = this.contentWrapperEl[this.axis[this.draggedAxis].scrollSizeAttr];
165
- const hostSize = parseInt(this.elStyles[this.axis[this.draggedAxis].sizeAttr], 10);
161
+ const hostSize = parseInt(
162
+ this.elStyles[this.axis[this.draggedAxis].sizeAttr],
163
+ 10
164
+ );
166
165
  e.preventDefault();
167
166
  e.stopPropagation();
168
167
  if (this.draggedAxis === "y") {
@@ -240,7 +239,10 @@ const _SimpleBar = class {
240
239
  }
241
240
  this.recalculate = lodashEs.throttle(this.recalculate.bind(this), 64);
242
241
  this.onMouseMove = lodashEs.throttle(this.onMouseMove.bind(this), 64);
243
- this.hideScrollbars = lodashEs.debounce(this.hideScrollbars.bind(this), this.options.timeout);
242
+ this.hideScrollbars = lodashEs.debounce(
243
+ this.hideScrollbars.bind(this),
244
+ this.options.timeout
245
+ );
244
246
  this.onWindowResize = lodashEs.debounce(this.onWindowResize.bind(this), 64, {
245
247
  leading: true
246
248
  });
@@ -257,7 +259,9 @@ const _SimpleBar = class {
257
259
  const dummyContainerOffset = _SimpleBar.getOffset(scrollbarDummyEl);
258
260
  const dummyContainerChildOffset = _SimpleBar.getOffset(dummyContainerChild);
259
261
  scrollbarDummyEl.scrollLeft = 999;
260
- const dummyContainerScrollOffsetAfterScroll = _SimpleBar.getOffset(dummyContainerChild);
262
+ const dummyContainerScrollOffsetAfterScroll = _SimpleBar.getOffset(
263
+ dummyContainerChild
264
+ );
261
265
  return {
262
266
  isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
263
267
  isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
@@ -274,7 +278,7 @@ const _SimpleBar = class {
274
278
  }
275
279
  init() {
276
280
  _SimpleBar.instances.set(this.el, this);
277
- if (canUseDOM__default) {
281
+ if (canUseDOM) {
278
282
  this.initDOM();
279
283
  this.setAccessibilityAttributes();
280
284
  this.scrollbarWidth = this.getScrollbarWidth();
@@ -283,17 +287,33 @@ const _SimpleBar = class {
283
287
  }
284
288
  }
285
289
  initDOM() {
286
- if (Array.prototype.filter.call(this.el.children, (child) => child.classList.contains(this.classNames.wrapper)).length) {
290
+ if (Array.prototype.filter.call(
291
+ this.el.children,
292
+ (child) => child.classList.contains(this.classNames.wrapper)
293
+ ).length) {
287
294
  this.wrapperEl = this.el.querySelector(`.${this.classNames.wrapper}`);
288
295
  this.contentWrapperEl = this.options.scrollableNode || this.el.querySelector(`.${this.classNames.contentWrapper}`);
289
296
  this.contentEl = this.options.contentNode || this.el.querySelector(`.${this.classNames.contentEl}`);
290
297
  this.offsetEl = this.el.querySelector(`.${this.classNames.offset}`);
291
298
  this.maskEl = this.el.querySelector(`.${this.classNames.mask}`);
292
- this.placeholderEl = this.findChild(this.wrapperEl, `.${this.classNames.placeholder}`);
293
- this.heightAutoObserverWrapperEl = this.el.querySelector(`.${this.classNames.heightAutoObserverWrapperEl}`);
294
- this.heightAutoObserverEl = this.el.querySelector(`.${this.classNames.heightAutoObserverEl}`);
295
- this.axis.x.track.el = this.findChild(this.el, `.${this.classNames.track}.${this.classNames.horizontal}`);
296
- this.axis.y.track.el = this.findChild(this.el, `.${this.classNames.track}.${this.classNames.vertical}`);
299
+ this.placeholderEl = this.findChild(
300
+ this.wrapperEl,
301
+ `.${this.classNames.placeholder}`
302
+ );
303
+ this.heightAutoObserverWrapperEl = this.el.querySelector(
304
+ `.${this.classNames.heightAutoObserverWrapperEl}`
305
+ );
306
+ this.heightAutoObserverEl = this.el.querySelector(
307
+ `.${this.classNames.heightAutoObserverEl}`
308
+ );
309
+ this.axis.x.track.el = this.findChild(
310
+ this.el,
311
+ `.${this.classNames.track}.${this.classNames.horizontal}`
312
+ );
313
+ this.axis.y.track.el = this.findChild(
314
+ this.el,
315
+ `.${this.classNames.track}.${this.classNames.vertical}`
316
+ );
297
317
  } else {
298
318
  this.wrapperEl = document.createElement("div");
299
319
  this.contentWrapperEl = document.createElement("div");
@@ -309,8 +329,12 @@ const _SimpleBar = class {
309
329
  this.maskEl.classList.add(this.classNames.mask);
310
330
  this.contentEl.classList.add(this.classNames.contentEl);
311
331
  this.placeholderEl.classList.add(this.classNames.placeholder);
312
- this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
313
- this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
332
+ this.heightAutoObserverWrapperEl.classList.add(
333
+ this.classNames.heightAutoObserverWrapperEl
334
+ );
335
+ this.heightAutoObserverEl.classList.add(
336
+ this.classNames.heightAutoObserverEl
337
+ );
314
338
  while (this.el.firstChild) {
315
339
  this.contentEl.appendChild(this.el.firstChild);
316
340
  }
@@ -336,8 +360,12 @@ const _SimpleBar = class {
336
360
  this.el.appendChild(this.axis.x.track.el);
337
361
  this.el.appendChild(this.axis.y.track.el);
338
362
  }
339
- this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector(`.${this.classNames.scrollbar}`);
340
- this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector(`.${this.classNames.scrollbar}`);
363
+ this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector(
364
+ `.${this.classNames.scrollbar}`
365
+ );
366
+ this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector(
367
+ `.${this.classNames.scrollbar}`
368
+ );
341
369
  if (!this.options.autoHide) {
342
370
  this.axis.x.scrollbar.el.classList.add(this.classNames.visible);
343
371
  this.axis.y.scrollbar.el.classList.add(this.classNames.visible);
@@ -433,7 +461,10 @@ const _SimpleBar = class {
433
461
  const trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
434
462
  let scrollbarSize;
435
463
  let scrollbarRatio = trackSize / contentSize;
436
- scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
464
+ scrollbarSize = Math.max(
465
+ ~~(scrollbarRatio * trackSize),
466
+ this.options.scrollbarMinSize
467
+ );
437
468
  if (this.options.scrollbarMaxSize) {
438
469
  scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
439
470
  }
@@ -477,7 +508,9 @@ const _SimpleBar = class {
477
508
  onMouseMoveForAxis(axis = "y") {
478
509
  this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
479
510
  this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
480
- const isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
511
+ const isWithinScrollbarBoundsX = this.isWithinBounds(
512
+ this.axis[axis].scrollbar.rect
513
+ );
481
514
  if (isWithinScrollbarBoundsX) {
482
515
  this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
483
516
  } else {
@@ -612,7 +645,10 @@ const _SimpleBar = class {
612
645
  }
613
646
  findChild(el, query) {
614
647
  const matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
615
- return Array.prototype.filter.call(el.children, (child) => matches.call(child, query))[0];
648
+ return Array.prototype.filter.call(
649
+ el.children,
650
+ (child) => matches.call(child, query)
651
+ )[0];
616
652
  }
617
653
  };
618
654
  let SimpleBar = _SimpleBar;
@@ -156,7 +156,10 @@ const _SimpleBar = class {
156
156
  const trackSize = track.rect[this.axis[this.draggedAxis].sizeAttr];
157
157
  const scrollbar = this.axis[this.draggedAxis].scrollbar;
158
158
  const contentSize = this.contentWrapperEl[this.axis[this.draggedAxis].scrollSizeAttr];
159
- const hostSize = parseInt(this.elStyles[this.axis[this.draggedAxis].sizeAttr], 10);
159
+ const hostSize = parseInt(
160
+ this.elStyles[this.axis[this.draggedAxis].sizeAttr],
161
+ 10
162
+ );
160
163
  e.preventDefault();
161
164
  e.stopPropagation();
162
165
  if (this.draggedAxis === "y") {
@@ -234,7 +237,10 @@ const _SimpleBar = class {
234
237
  }
235
238
  this.recalculate = throttle(this.recalculate.bind(this), 64);
236
239
  this.onMouseMove = throttle(this.onMouseMove.bind(this), 64);
237
- this.hideScrollbars = debounce(this.hideScrollbars.bind(this), this.options.timeout);
240
+ this.hideScrollbars = debounce(
241
+ this.hideScrollbars.bind(this),
242
+ this.options.timeout
243
+ );
238
244
  this.onWindowResize = debounce(this.onWindowResize.bind(this), 64, {
239
245
  leading: true
240
246
  });
@@ -251,7 +257,9 @@ const _SimpleBar = class {
251
257
  const dummyContainerOffset = _SimpleBar.getOffset(scrollbarDummyEl);
252
258
  const dummyContainerChildOffset = _SimpleBar.getOffset(dummyContainerChild);
253
259
  scrollbarDummyEl.scrollLeft = 999;
254
- const dummyContainerScrollOffsetAfterScroll = _SimpleBar.getOffset(dummyContainerChild);
260
+ const dummyContainerScrollOffsetAfterScroll = _SimpleBar.getOffset(
261
+ dummyContainerChild
262
+ );
255
263
  return {
256
264
  isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
257
265
  isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
@@ -277,17 +285,33 @@ const _SimpleBar = class {
277
285
  }
278
286
  }
279
287
  initDOM() {
280
- if (Array.prototype.filter.call(this.el.children, (child) => child.classList.contains(this.classNames.wrapper)).length) {
288
+ if (Array.prototype.filter.call(
289
+ this.el.children,
290
+ (child) => child.classList.contains(this.classNames.wrapper)
291
+ ).length) {
281
292
  this.wrapperEl = this.el.querySelector(`.${this.classNames.wrapper}`);
282
293
  this.contentWrapperEl = this.options.scrollableNode || this.el.querySelector(`.${this.classNames.contentWrapper}`);
283
294
  this.contentEl = this.options.contentNode || this.el.querySelector(`.${this.classNames.contentEl}`);
284
295
  this.offsetEl = this.el.querySelector(`.${this.classNames.offset}`);
285
296
  this.maskEl = this.el.querySelector(`.${this.classNames.mask}`);
286
- this.placeholderEl = this.findChild(this.wrapperEl, `.${this.classNames.placeholder}`);
287
- this.heightAutoObserverWrapperEl = this.el.querySelector(`.${this.classNames.heightAutoObserverWrapperEl}`);
288
- this.heightAutoObserverEl = this.el.querySelector(`.${this.classNames.heightAutoObserverEl}`);
289
- this.axis.x.track.el = this.findChild(this.el, `.${this.classNames.track}.${this.classNames.horizontal}`);
290
- this.axis.y.track.el = this.findChild(this.el, `.${this.classNames.track}.${this.classNames.vertical}`);
297
+ this.placeholderEl = this.findChild(
298
+ this.wrapperEl,
299
+ `.${this.classNames.placeholder}`
300
+ );
301
+ this.heightAutoObserverWrapperEl = this.el.querySelector(
302
+ `.${this.classNames.heightAutoObserverWrapperEl}`
303
+ );
304
+ this.heightAutoObserverEl = this.el.querySelector(
305
+ `.${this.classNames.heightAutoObserverEl}`
306
+ );
307
+ this.axis.x.track.el = this.findChild(
308
+ this.el,
309
+ `.${this.classNames.track}.${this.classNames.horizontal}`
310
+ );
311
+ this.axis.y.track.el = this.findChild(
312
+ this.el,
313
+ `.${this.classNames.track}.${this.classNames.vertical}`
314
+ );
291
315
  } else {
292
316
  this.wrapperEl = document.createElement("div");
293
317
  this.contentWrapperEl = document.createElement("div");
@@ -303,8 +327,12 @@ const _SimpleBar = class {
303
327
  this.maskEl.classList.add(this.classNames.mask);
304
328
  this.contentEl.classList.add(this.classNames.contentEl);
305
329
  this.placeholderEl.classList.add(this.classNames.placeholder);
306
- this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
307
- this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
330
+ this.heightAutoObserverWrapperEl.classList.add(
331
+ this.classNames.heightAutoObserverWrapperEl
332
+ );
333
+ this.heightAutoObserverEl.classList.add(
334
+ this.classNames.heightAutoObserverEl
335
+ );
308
336
  while (this.el.firstChild) {
309
337
  this.contentEl.appendChild(this.el.firstChild);
310
338
  }
@@ -330,8 +358,12 @@ const _SimpleBar = class {
330
358
  this.el.appendChild(this.axis.x.track.el);
331
359
  this.el.appendChild(this.axis.y.track.el);
332
360
  }
333
- this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector(`.${this.classNames.scrollbar}`);
334
- this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector(`.${this.classNames.scrollbar}`);
361
+ this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector(
362
+ `.${this.classNames.scrollbar}`
363
+ );
364
+ this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector(
365
+ `.${this.classNames.scrollbar}`
366
+ );
335
367
  if (!this.options.autoHide) {
336
368
  this.axis.x.scrollbar.el.classList.add(this.classNames.visible);
337
369
  this.axis.y.scrollbar.el.classList.add(this.classNames.visible);
@@ -427,7 +459,10 @@ const _SimpleBar = class {
427
459
  const trackSize = this.axis[axis].track.el[this.axis[axis].offsetSizeAttr];
428
460
  let scrollbarSize;
429
461
  let scrollbarRatio = trackSize / contentSize;
430
- scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
462
+ scrollbarSize = Math.max(
463
+ ~~(scrollbarRatio * trackSize),
464
+ this.options.scrollbarMinSize
465
+ );
431
466
  if (this.options.scrollbarMaxSize) {
432
467
  scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
433
468
  }
@@ -471,7 +506,9 @@ const _SimpleBar = class {
471
506
  onMouseMoveForAxis(axis = "y") {
472
507
  this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
473
508
  this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
474
- const isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
509
+ const isWithinScrollbarBoundsX = this.isWithinBounds(
510
+ this.axis[axis].scrollbar.rect
511
+ );
475
512
  if (isWithinScrollbarBoundsX) {
476
513
  this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
477
514
  } else {
@@ -606,7 +643,10 @@ const _SimpleBar = class {
606
643
  }
607
644
  findChild(el, query) {
608
645
  const matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
609
- return Array.prototype.filter.call(el.children, (child) => matches.call(child, query))[0];
646
+ return Array.prototype.filter.call(
647
+ el.children,
648
+ (child) => matches.call(child, query)
649
+ )[0];
610
650
  }
611
651
  };
612
652
  let SimpleBar = _SimpleBar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karta.io/simplebar",
3
- "version": "0.20.4",
3
+ "version": "0.21.0",
4
4
  "description": "Клон core части библиотеки simplebar",
5
5
  "files": [
6
6
  "dist",
@@ -25,7 +25,7 @@
25
25
  "lodash-es": "4.17.21"
26
26
  },
27
27
  "devDependencies": {
28
- "unbuild": "0.7.4"
28
+ "unbuild": "1.0.1"
29
29
  },
30
30
  "lint-staged": {
31
31
  "*.{js,jsx,json}": [