@ruckc/truss-code 1.26.0 → 1.26.1

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.
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { onMount, tick, untrack, type Snippet } from 'svelte';
3
- import { Button, SegmentedControl } from '@ruckc/truss-ui';
3
+ import { Button, SegmentedControl, startDrag } from '@ruckc/truss-ui';
4
4
  import {
5
5
  diffLines, intraline, foldItems, expandFold, changeStarts, describeChange, diffStats, pairLines, inlineWords, hunkSpans, toHunks, formatHunks, hunkHeader,
6
6
  sideIndex, firstAtLeast, lineNo, selectedLines, parseLineRef, locateLine,
@@ -157,7 +157,8 @@
157
157
  let hitCur = $state(-1);
158
158
  const heights = new Map<string, number>();
159
159
  let anchor: { side: Side; n: number } | null = null;
160
- let dragging = false;
160
+ let stopOv: (() => void) | undefined; // the running overview drag, abandoned if the view unmounts mid-drag
161
+ $effect(() => () => stopOv?.());
161
162
  let raf = 0;
162
163
  let timer: ReturnType<typeof setTimeout> | undefined;
163
164
 
@@ -547,6 +548,10 @@
547
548
  // where the part in view sits on the ruler, as percentages (all of it before anything is measured)
548
549
  const thumb = $derived<[number, number]>(content > 0 ? [(top / content) * 100, Math.min(100, (vh / content) * 100)] : [0, 100]);
549
550
  const showOv = $derived(overview ?? content > vh + 1);
551
+ function ovDown(e: PointerEvent) {
552
+ stopOv = startDrag(e, { move: ovScroll, cursor: 'ns-resize', end: () => (stopOv = undefined) });
553
+ if (stopOv) ovScroll(e);
554
+ }
550
555
  function ovScroll(e: PointerEvent) {
551
556
  const r = ov!.getBoundingClientRect();
552
557
  scroller!.scrollTop = Math.min(1, Math.max(0, (e.clientY - r.top) / r.height)) * content - vh / 2;
@@ -649,10 +654,7 @@
649
654
  aria-label={overviewText}
650
655
  title={overviewText}
651
656
  data-testid="overview"
652
- onpointerdown={(e) => { dragging = true; ov!.setPointerCapture(e.pointerId); ovScroll(e); }}
653
- onpointermove={(e) => dragging && ovScroll(e)}
654
- onpointerup={() => (dragging = false)}
655
- onpointercancel={() => (dragging = false)}
657
+ onpointerdown={ovDown}
656
658
  >
657
659
  {#each runs as r}<span class="mk {r.lane}" style:top="{r.from}%" style:height="{r.to - r.from}%"></span>{/each}
658
660
  <span class="thumb" style:top="{thumb[0]}%" style:height="{thumb[1]}%"></span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruckc/truss-code",
3
- "version": "1.26.0",
3
+ "version": "1.26.1",
4
4
  "description": "Read-only code blocks, diff and merge views, plus an optional Monaco code editor, styled with Truss UI",
5
5
  "type": "module",
6
6
  "license": "MIT",