@fundar/data-chart-telling 0.0.16 → 0.0.17

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.
@@ -26,11 +26,26 @@
26
26
  // ── Drag-to-narrow-margins ────────────────────────────────────────────────
27
27
  const interaction = getLegendInteraction() ?? createLegendInteraction();
28
28
 
29
- // Seeded once from the section's own bounds (deliberately untracked — this
30
- // component doesn't follow later `section.min`/`max` prop changes).
29
+ // Seeded once from the section's own bounds (deliberately untracked — a
30
+ // later `section.min`/`max` change re-clamps the existing lo/hi instead of
31
+ // resetting them back out to the new full range, see below).
31
32
  let lo = $state(untrack(() => section.min));
32
33
  let hi = $state(untrack(() => section.max));
33
34
 
35
+ // `section.min`/`max` can shift under an already-active selection — e.g. a
36
+ // consumer swaps `data` for a different year on its own timeline, and the
37
+ // value that used to be the max is no longer present. Re-clamping (instead
38
+ // of leaving lo/hi at their old absolute values) keeps the handles inside
39
+ // whatever range now actually exists: the lower handle can only move up to
40
+ // meet a risen min, the upper handle can only move down to meet a fallen
41
+ // max. Clamping each bound against *both* of the new min/max first (not
42
+ // just its own side) keeps lo/hi from inverting if the domain shifts
43
+ // entirely past the old selection.
44
+ $effect(() => {
45
+ lo = Math.min(Math.max(lo, section.min), section.max);
46
+ hi = Math.max(Math.min(hi, section.max), section.min);
47
+ });
48
+
34
49
  function toT(v: number): number {
35
50
  return (v - section.min) / (section.max - section.min || 1);
36
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fundar/data-chart-telling",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"