negodesign 0.0.72 → 0.0.73

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.
@@ -55,22 +55,29 @@
55
55
  );
56
56
  }
57
57
 
58
+ function snapsEqual(a: number[], b: number[]): boolean {
59
+ if (a.length !== b.length) return false;
60
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
61
+ return true;
62
+ }
63
+
58
64
  function updateScrollSnaps() {
59
65
  const container = ctx.containerEl;
60
66
  if (!container) {
61
- ctx.scrollSnaps = [];
67
+ if (ctx.scrollSnaps.length > 0) ctx.scrollSnaps = [];
62
68
  return;
63
69
  }
64
70
  const scrollPos = isVertical ? container.scrollTop : container.scrollLeft;
65
71
  const origin = isVertical
66
72
  ? container.getBoundingClientRect().top
67
73
  : container.getBoundingClientRect().left;
68
- ctx.scrollSnaps = getSlides().map((slide) => {
74
+ const next = getSlides().map((slide) => {
69
75
  const slidePos = isVertical
70
76
  ? slide.getBoundingClientRect().top
71
77
  : slide.getBoundingClientRect().left;
72
78
  return slidePos - origin + scrollPos;
73
79
  });
80
+ if (!snapsEqual(ctx.scrollSnaps, next)) ctx.scrollSnaps = next;
74
81
  }
75
82
 
76
83
  function onScroll() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "negodesign",
3
- "version": "0.0.72",
3
+ "version": "0.0.73",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "sideEffects": [