@oxog/scrollex 1.1.1 → 1.2.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.
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkMEEFAXSA_cjs = require('./chunk-MEEFAXSA.cjs');
3
+ var chunkCTKEJZGD_cjs = require('./chunk-CTKEJZGD.cjs');
4
4
  var react = require('react');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
 
@@ -271,7 +271,9 @@ var ScrollEngine = class {
271
271
  this.previousScrollPosition = { ...this.scrollPosition };
272
272
  this.reportedPosition = { ...this.scrollPosition };
273
273
  this.throttledHandleScroll = throttleRAF(this.processScroll.bind(this));
274
- this.boundHandleScroll = () => this.throttledHandleScroll?.();
274
+ this.boundHandleScroll = () => {
275
+ this.throttledHandleScroll?.();
276
+ };
275
277
  container.addEventListener("scroll", this.boundHandleScroll, { passive: true });
276
278
  }
277
279
  /**
@@ -299,7 +301,7 @@ var ScrollEngine = class {
299
301
  this.scrollEndTimer = null;
300
302
  }
301
303
  if (this.animationId) {
302
- chunkMEEFAXSA_cjs.cancelRaf(this.animationId);
304
+ chunkCTKEJZGD_cjs.cancelRaf(this.animationId);
303
305
  this.animationId = null;
304
306
  }
305
307
  this.boundHandleScroll = null;
@@ -370,7 +372,7 @@ var ScrollEngine = class {
370
372
  setScrollPosition(position) {
371
373
  if (!this.container) return;
372
374
  if (this.animationId) {
373
- chunkMEEFAXSA_cjs.cancelRaf(this.animationId);
375
+ chunkCTKEJZGD_cjs.cancelRaf(this.animationId);
374
376
  this.animationId = null;
375
377
  }
376
378
  setScrollPosition(this.container, position);
@@ -402,7 +404,7 @@ var ScrollEngine = class {
402
404
  */
403
405
  animateScroll(targetOffset, duration, easing) {
404
406
  if (this.animationId) {
405
- chunkMEEFAXSA_cjs.cancelRaf(this.animationId);
407
+ chunkCTKEJZGD_cjs.cancelRaf(this.animationId);
406
408
  }
407
409
  this.animationStartTime = performance.now();
408
410
  this.animationStartOffset = this.horizontal ? this.scrollPosition.scrollLeft : this.scrollPosition.scrollTop;
@@ -416,12 +418,12 @@ var ScrollEngine = class {
416
418
  const currentOffset = this.animationStartOffset + (this.animationTargetOffset - this.animationStartOffset) * easedProgress;
417
419
  this.setScrollPosition(this.horizontal ? { scrollLeft: currentOffset } : { scrollTop: currentOffset });
418
420
  if (progress < 1) {
419
- this.animationId = chunkMEEFAXSA_cjs.raf(animate);
421
+ this.animationId = chunkCTKEJZGD_cjs.raf(animate);
420
422
  } else {
421
423
  this.animationId = null;
422
424
  }
423
425
  };
424
- this.animationId = chunkMEEFAXSA_cjs.raf(animate);
426
+ this.animationId = chunkCTKEJZGD_cjs.raf(animate);
425
427
  }
426
428
  /**
427
429
  * Check if currently scrolling.
@@ -508,7 +510,7 @@ var ScrollEngine = class {
508
510
  */
509
511
  stopAnimation() {
510
512
  if (this.animationId) {
511
- chunkMEEFAXSA_cjs.cancelRaf(this.animationId);
513
+ chunkCTKEJZGD_cjs.cancelRaf(this.animationId);
512
514
  this.animationId = null;
513
515
  }
514
516
  }
@@ -986,7 +988,7 @@ var RangeCalculator = class {
986
988
  const itemEnd = this.getItemEnd(mid);
987
989
  return itemEnd > scrollOffset;
988
990
  });
989
- return chunkMEEFAXSA_cjs.clamp(index, 0, this.itemCount - 1);
991
+ return chunkCTKEJZGD_cjs.clamp(index, 0, this.itemCount - 1);
990
992
  }
991
993
  /**
992
994
  * Find the end index for a given scroll end position.
@@ -997,7 +999,7 @@ var RangeCalculator = class {
997
999
  while (index < this.itemCount - 1 && this.getItemOffset(index + 1) < scrollEnd) {
998
1000
  index++;
999
1001
  }
1000
- return chunkMEEFAXSA_cjs.clamp(index, startIndex, this.itemCount - 1);
1002
+ return chunkCTKEJZGD_cjs.clamp(index, startIndex, this.itemCount - 1);
1001
1003
  }
1002
1004
  /**
1003
1005
  * Get the offset (start position) of an item.
@@ -1478,7 +1480,7 @@ var DEFAULT_OPTIONS = {
1478
1480
  };
1479
1481
  function createKernel(options = {}) {
1480
1482
  const config = { ...DEFAULT_OPTIONS, ...options };
1481
- config.overscan = chunkMEEFAXSA_cjs.normalizeOverscan(config.overscan);
1483
+ config.overscan = chunkCTKEJZGD_cjs.normalizeOverscan(config.overscan);
1482
1484
  const eventBus = new EventBus();
1483
1485
  const scrollEngine = new ScrollEngine();
1484
1486
  scrollEngine.setDirection(config.direction);
@@ -1659,7 +1661,7 @@ function createKernel(options = {}) {
1659
1661
  rangeCalculator.setEstimatedHeight(newOptions.estimatedItemHeight);
1660
1662
  }
1661
1663
  if (newOptions.overscan !== void 0) {
1662
- config.overscan = chunkMEEFAXSA_cjs.normalizeOverscan(newOptions.overscan);
1664
+ config.overscan = chunkCTKEJZGD_cjs.normalizeOverscan(newOptions.overscan);
1663
1665
  rangeCalculator.setOverscan(config.overscan);
1664
1666
  }
1665
1667
  if (newOptions.direction !== void 0) {
@@ -1854,7 +1856,7 @@ function useVirtualList(options) {
1854
1856
  const resizeObserverRef = react.useRef(null);
1855
1857
  const kernel = kernelRef.current;
1856
1858
  react.useEffect(() => {
1857
- const plugin = chunkMEEFAXSA_cjs.listRendererPlugin({ getItemKey: (index) => getItemKeyRef.current(index) });
1859
+ const plugin = chunkCTKEJZGD_cjs.listRendererPlugin({ getItemKey: (index) => getItemKeyRef.current(index) });
1858
1860
  kernel.register(plugin);
1859
1861
  listRendererRef.current = plugin.api;
1860
1862
  const unsubScroll = kernel.on("scroll", (event) => {
@@ -2296,7 +2298,7 @@ function useVirtualGrid(options) {
2296
2298
  overscanStartIndex: 0,
2297
2299
  overscanEndIndex: 0
2298
2300
  });
2299
- const [columnCount, setColumnCount] = react.useState(typeof columns === "number" ? chunkMEEFAXSA_cjs.normalizeColumnCount(columns) : 1);
2301
+ const [columnCount, setColumnCount] = react.useState(typeof columns === "number" ? chunkCTKEJZGD_cjs.normalizeColumnCount(columns) : 1);
2300
2302
  const [columnWidth, setColumnWidth] = react.useState(0);
2301
2303
  const gridRendererRef = react.useRef(null);
2302
2304
  const kernel = kernelRef.current;
@@ -2308,7 +2310,7 @@ function useVirtualGrid(options) {
2308
2310
  if (api && itemCount > 0) kernel.configure({ estimatedItemHeight: api.getTotalHeight() / itemCount });
2309
2311
  }, [kernel]);
2310
2312
  react.useEffect(() => {
2311
- const plugin = chunkMEEFAXSA_cjs.gridRendererPlugin({
2313
+ const plugin = chunkCTKEJZGD_cjs.gridRendererPlugin({
2312
2314
  columns,
2313
2315
  minColumnWidth,
2314
2316
  rowHeight,
@@ -2705,7 +2707,7 @@ function useVirtualMasonry(options) {
2705
2707
  overscanStartIndex: 0,
2706
2708
  overscanEndIndex: 0
2707
2709
  });
2708
- const [columnCount, setColumnCount] = react.useState(typeof columns === "number" ? chunkMEEFAXSA_cjs.normalizeColumnCount(columns) : 1);
2710
+ const [columnCount, setColumnCount] = react.useState(typeof columns === "number" ? chunkCTKEJZGD_cjs.normalizeColumnCount(columns) : 1);
2709
2711
  const [columnWidth, setColumnWidth] = react.useState(0);
2710
2712
  const [columnHeights, setColumnHeights] = react.useState([]);
2711
2713
  const [totalSize, setTotalSize] = react.useState(0);
@@ -2724,7 +2726,7 @@ function useVirtualMasonry(options) {
2724
2726
  setTotalSize(0);
2725
2727
  return;
2726
2728
  }
2727
- const columnTotal = columns === "auto" ? chunkMEEFAXSA_cjs.autoColumnCount(containerWidth, minColumnWidth, gapX) : chunkMEEFAXSA_cjs.normalizeColumnCount(columns);
2729
+ const columnTotal = columns === "auto" ? chunkCTKEJZGD_cjs.autoColumnCount(containerWidth, minColumnWidth, gapX) : chunkCTKEJZGD_cjs.normalizeColumnCount(columns);
2728
2730
  const newColumnWidth = (containerWidth - (columnTotal - 1) * gapX) / columnTotal;
2729
2731
  setColumnCount(columnTotal);
2730
2732
  setColumnWidth(newColumnWidth);
@@ -2755,7 +2757,7 @@ function useVirtualMasonry(options) {
2755
2757
  const getVisibleItems = react.useCallback((scrollTop, viewportHeight) => {
2756
2758
  const cache = layoutCacheRef.current;
2757
2759
  const items = [];
2758
- const overscanAmount = chunkMEEFAXSA_cjs.normalizeOverscan(overscan) * 100;
2760
+ const overscanAmount = chunkCTKEJZGD_cjs.normalizeOverscan(overscan) * 100;
2759
2761
  const viewStart = Math.max(0, scrollTop - overscanAmount);
2760
2762
  const viewEnd = scrollTop + viewportHeight + overscanAmount;
2761
2763
  for (let i = 0; i < count; i++) {
@@ -3262,23 +3264,23 @@ function useMeasureMany() {
3262
3264
 
3263
3265
  Object.defineProperty(exports, "autoMeasurerPlugin", {
3264
3266
  enumerable: true,
3265
- get: function () { return chunkMEEFAXSA_cjs.autoMeasurerPlugin; }
3267
+ get: function () { return chunkCTKEJZGD_cjs.autoMeasurerPlugin; }
3266
3268
  });
3267
3269
  Object.defineProperty(exports, "gridRendererPlugin", {
3268
3270
  enumerable: true,
3269
- get: function () { return chunkMEEFAXSA_cjs.gridRendererPlugin; }
3271
+ get: function () { return chunkCTKEJZGD_cjs.gridRendererPlugin; }
3270
3272
  });
3271
3273
  Object.defineProperty(exports, "infiniteLoaderPlugin", {
3272
3274
  enumerable: true,
3273
- get: function () { return chunkMEEFAXSA_cjs.infiniteLoaderPlugin; }
3275
+ get: function () { return chunkCTKEJZGD_cjs.infiniteLoaderPlugin; }
3274
3276
  });
3275
3277
  Object.defineProperty(exports, "listRendererPlugin", {
3276
3278
  enumerable: true,
3277
- get: function () { return chunkMEEFAXSA_cjs.listRendererPlugin; }
3279
+ get: function () { return chunkCTKEJZGD_cjs.listRendererPlugin; }
3278
3280
  });
3279
3281
  Object.defineProperty(exports, "scrollControllerPlugin", {
3280
3282
  enumerable: true,
3281
- get: function () { return chunkMEEFAXSA_cjs.scrollControllerPlugin; }
3283
+ get: function () { return chunkCTKEJZGD_cjs.scrollControllerPlugin; }
3282
3284
  });
3283
3285
  exports.VirtualGrid = VirtualGrid;
3284
3286
  exports.VirtualList = VirtualList;