scroll-arrows 0.1.3 → 0.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.
@@ -5,6 +5,12 @@ type Point = {
5
5
  /** Which edge of an element the arrow attaches to. `auto` picks the best side. */
6
6
  type Socket = 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'center';
7
7
  type ArrowHead = 'start' | 'end' | 'both' | 'none';
8
+ /**
9
+ * Line routing style. `curved` (default) is the smooth bezier with single-bend
10
+ * obstacle avoidance. `elbow` draws right-angle connectors (tree/org-chart
11
+ * brackets); `elbow` ignores `avoid`/`curvature`.
12
+ */
13
+ type Route = 'curved' | 'elbow';
8
14
  /** Anything we can resolve to a live DOM element. */
9
15
  type ElementRef = Element | string;
10
16
  interface ScrollOptions {
@@ -48,8 +54,24 @@ interface ScrollArrowOptions {
48
54
  startSocket?: Socket;
49
55
  /** Force an end edge. Default "auto". */
50
56
  endSocket?: Socket;
57
+ /**
58
+ * Slide the start attach point along its edge, as a fraction of the edge
59
+ * length: `0` (default) = centered, `-0.5`/`+0.5` = the corners. Use to fan
60
+ * out several arrows that leave the same element so they don't stack on one
61
+ * point (e.g. `-0.25`, `0`, `+0.25` for three siblings).
62
+ */
63
+ startSocketOffset?: number;
64
+ /** Slide the end attach point along its edge. See `startSocketOffset`. */
65
+ endSocketOffset?: number;
51
66
  /** Extra bow of the underlying curve, 0..1. Folded into roughness if unset. */
52
67
  curvature?: number;
68
+ /**
69
+ * Routing style. `"curved"` (default) is the smooth bezier with obstacle
70
+ * avoidance; `"elbow"` draws right-angle connectors for tree/org-chart
71
+ * diagrams. Elbow mode ignores `avoid` and `curvature`. Pair with explicit
72
+ * `startSocket`/`endSocket` for predictable bracket shapes.
73
+ */
74
+ route?: Route;
53
75
  /**
54
76
  * Pin the stroke's endpoints to the anchor sockets so the arrow always lands
55
77
  * on its targets, even at high roughness. Set false to let the scratchy ends
@@ -99,6 +121,62 @@ interface ScrollArrowOptions {
99
121
  easing?: (t: number) => number;
100
122
  /** Start fully drawn instead of empty. Useful with `scroll:false`. Default 0. */
101
123
  progress?: number;
124
+ /**
125
+ * Auto-respect `prefers-reduced-motion: reduce`. When the user prefers reduced
126
+ * motion, the arrow renders fully drawn and static (no scroll animation),
127
+ * while still tracking layout. Set false to keep the scroll animation
128
+ * regardless of the OS setting. Default true. Evaluated once at construction.
129
+ */
130
+ respectReducedMotion?: boolean;
131
+ /**
132
+ * Initial enabled state. When `false`, the arrow is created hidden and draws
133
+ * nothing until `setEnabled(true)` is called. Use with a `matchMedia` listener
134
+ * to switch arrows off below a breakpoint (where the diagram reflows) without
135
+ * destroying and rebuilding them. Default true.
136
+ */
137
+ enabled?: boolean;
138
+ }
139
+ /**
140
+ * A coordinated set of arrows that draw in a staggered sequence, driven by one
141
+ * shared scroll trigger (or manually). Each arrow gets a slice of the group's
142
+ * progress so they reveal as `A then B then C` rather than independently.
143
+ */
144
+ interface ScrollArrowGroupOptions {
145
+ /**
146
+ * The arrows in the group, in reveal order. Each entry takes the usual
147
+ * per-arrow options (roughness, stroke, label, ...); the group forces
148
+ * `scroll: false` on each and drives their progress itself.
149
+ */
150
+ arrows: ScrollArrowOptions[];
151
+ /**
152
+ * How sequential the reveal is, 0..1. `1` (default) draws each arrow in its
153
+ * own non-overlapping slice (`A` finishes before `B` starts). `0` draws them
154
+ * all at once. Values between overlap the slices.
155
+ */
156
+ stagger?: number;
157
+ /**
158
+ * Shared scroll behavior for the whole group. Pass `false` to drive the group
159
+ * manually via `setProgress()`. The `target` defaults to a synthetic rect
160
+ * spanning every arrow's endpoints, so the group reveals as it scrolls in.
161
+ */
162
+ scroll?: ScrollOptions | false;
163
+ /** Multiplier on the group's draw rate. See `ScrollArrowOptions.speed`. Default 1. */
164
+ speed?: number;
165
+ /** Easing applied to the group's overall progress before slicing. Default linear. */
166
+ easing?: (t: number) => number;
167
+ /**
168
+ * Auto-respect `prefers-reduced-motion: reduce` for the whole group. When the
169
+ * user prefers reduced motion, every arrow renders fully drawn and static (no
170
+ * scroll animation). Set false to keep the staggered scroll reveal regardless
171
+ * of the OS setting. Default true. Evaluated once at construction.
172
+ */
173
+ respectReducedMotion?: boolean;
174
+ /**
175
+ * Initial enabled state for the whole group. When `false`, every arrow starts
176
+ * hidden until `setEnabled(true)`. Pairs with a `matchMedia` listener for
177
+ * breakpoint-aware diagrams. Default true.
178
+ */
179
+ enabled?: boolean;
102
180
  }
103
181
 
104
- export type { ArrowHead as A, ElementRef as E, Point as P, ScrollArrowOptions as S, ScrollOptions as a, Socket as b };
182
+ export type { ArrowHead as A, ElementRef as E, Point as P, ScrollArrowOptions as S, ScrollArrowGroupOptions as a, ScrollOptions as b, Socket as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scroll-arrows",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Hand-drawn arrows that draw themselves between two elements as you scroll. Roughness goes from clean straight lines to scratchy and curvy.",
5
5
  "type": "module",
6
6
  "sideEffects": false,