@open-slide/core 1.13.0 → 1.13.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.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Locale, Plural } from "./types-CHmFPIG_.js";
2
2
  import { OpenSlideConfig } from "./config-x493taft.js";
3
3
  import { CSSProperties, ComponentType, HTMLAttributes, PropsWithChildren, ReactNode } from "react";
4
- import * as react_jsx_runtime4 from "react/jsx-runtime";
5
- import * as react_jsx_runtime3 from "react/jsx-runtime";
6
4
  import * as react_jsx_runtime1 from "react/jsx-runtime";
7
5
  import * as react_jsx_runtime2 from "react/jsx-runtime";
6
+ import * as react_jsx_runtime4 from "react/jsx-runtime";
7
+ import * as react_jsx_runtime5 from "react/jsx-runtime";
8
8
 
9
9
  //#region src/app/components/image-placeholder.d.ts
10
10
  type ImagePlaceholderProps = {
@@ -21,7 +21,7 @@ declare function ImagePlaceholder({
21
21
  style,
22
22
  className,
23
23
  ...rest
24
- }: ImagePlaceholderProps): react_jsx_runtime4.JSX.Element;
24
+ }: ImagePlaceholderProps): react_jsx_runtime1.JSX.Element;
25
25
 
26
26
  //#endregion
27
27
  //#region src/app/components/shared-element.d.ts
@@ -36,7 +36,7 @@ declare function unstable_SharedElement({
36
36
  children,
37
37
  className,
38
38
  style
39
- }: unstable_SharedElementProps): react_jsx_runtime3.JSX.Element;
39
+ }: unstable_SharedElementProps): react_jsx_runtime2.JSX.Element;
40
40
 
41
41
  //#endregion
42
42
  //#region src/app/lib/design.d.ts
@@ -117,7 +117,7 @@ declare const CANVAS_HEIGHT = 1080;
117
117
  type StepsProps = PropsWithChildren;
118
118
  declare function Steps({
119
119
  children
120
- }: StepsProps): react_jsx_runtime1.JSX.Element;
120
+ }: StepsProps): react_jsx_runtime4.JSX.Element;
121
121
  type StepProps = PropsWithChildren<{
122
122
  duration?: number;
123
123
  }>;
@@ -128,7 +128,7 @@ declare function Step({
128
128
  children,
129
129
  duration,
130
130
  _revealed
131
- }: InternalStepProps): react_jsx_runtime2.JSX.Element;
131
+ }: InternalStepProps): react_jsx_runtime5.JSX.Element;
132
132
 
133
133
  //#endregion
134
134
  export { CANVAS_HEIGHT, CANVAS_WIDTH, DesignFonts, DesignPalette, DesignSystem, DesignTypeScale, ImagePlaceholder, ImagePlaceholderProps, Locale, OpenSlideConfig, Page, Plural, SharedElementTransition, SlideMeta, SlideModule, SlideTransition, Step, StepProps, Steps, StepsProps, TransitionPhase, cssVarsToString, defaultDesign, designToCssVars, unstable_SharedElement, unstable_SharedElementProps, useSlidePageNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-slide/core",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "Runtime and CLI for open-slide — write slides in slides/, we handle the rest.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -45,6 +45,46 @@ const SHARED_ELEMENT_VISUAL_PROPERTIES = [
45
45
  'fill',
46
46
  'stroke',
47
47
  ] as const;
48
+ const BORDER_COLOR_PROPERTIES = [
49
+ 'border-top-color',
50
+ 'border-right-color',
51
+ 'border-bottom-color',
52
+ 'border-left-color',
53
+ ] as const;
54
+ const BORDER_SIDE_PROPERTIES = [
55
+ {
56
+ width: 'borderTopWidth',
57
+ style: 'borderTopStyle',
58
+ color: 'borderTopColor',
59
+ cssWidth: 'border-top-width',
60
+ cssStyle: 'border-top-style',
61
+ cssColor: 'border-top-color',
62
+ },
63
+ {
64
+ width: 'borderRightWidth',
65
+ style: 'borderRightStyle',
66
+ color: 'borderRightColor',
67
+ cssWidth: 'border-right-width',
68
+ cssStyle: 'border-right-style',
69
+ cssColor: 'border-right-color',
70
+ },
71
+ {
72
+ width: 'borderBottomWidth',
73
+ style: 'borderBottomStyle',
74
+ color: 'borderBottomColor',
75
+ cssWidth: 'border-bottom-width',
76
+ cssStyle: 'border-bottom-style',
77
+ cssColor: 'border-bottom-color',
78
+ },
79
+ {
80
+ width: 'borderLeftWidth',
81
+ style: 'borderLeftStyle',
82
+ color: 'borderLeftColor',
83
+ cssWidth: 'border-left-width',
84
+ cssStyle: 'border-left-style',
85
+ cssColor: 'border-left-color',
86
+ },
87
+ ] as const;
48
88
  const INHERITED_VISUAL_PROPERTIES = new Set<string>([
49
89
  'color',
50
90
  'text-decoration-color',
@@ -222,13 +262,27 @@ function sharedElementTransform(
222
262
  .join(' ');
223
263
  }
224
264
 
265
+ function sharedElementTranslateTransform(rect: LocalRect, local: string): string {
266
+ return [`translate(${rect.left}px, ${rect.top}px)`, local].filter(Boolean).join(' ');
267
+ }
268
+
225
269
  function getStyleProperty(styles: CSSStyleDeclaration, css: string): string {
226
270
  return styles.getPropertyValue(css);
227
271
  }
228
272
 
229
- function visualStyleKeyframe(styles: CSSStyleDeclaration, opacity?: string): Keyframe {
273
+ function visualStyleKeyframe(
274
+ styles: CSSStyleDeclaration,
275
+ opacity?: string,
276
+ options: { includeBorderColors?: boolean } = {},
277
+ ): Keyframe {
230
278
  const frame: Record<string, string> = {};
231
279
  for (const prop of SHARED_ELEMENT_VISUAL_PROPERTIES) {
280
+ if (
281
+ options.includeBorderColors === false &&
282
+ (BORDER_COLOR_PROPERTIES as readonly string[]).includes(prop)
283
+ ) {
284
+ continue;
285
+ }
232
286
  const value = getStyleProperty(styles, prop);
233
287
  if (prop === TEXT_FILL_COLOR_PROPERTY && value === styles.color) continue;
234
288
  if (value) frame[prop] = value;
@@ -237,6 +291,80 @@ function visualStyleKeyframe(styles: CSSStyleDeclaration, opacity?: string): Key
237
291
  return frame;
238
292
  }
239
293
 
294
+ function hideBorderColors(el: HTMLElement): void {
295
+ for (const { color } of BORDER_SIDE_PROPERTIES) {
296
+ el.style[color] = 'transparent';
297
+ }
298
+ }
299
+
300
+ function isVisibleBorderSide(
301
+ styles: CSSStyleDeclaration,
302
+ side: (typeof BORDER_SIDE_PROPERTIES)[number],
303
+ ): boolean {
304
+ const width = parsePx(getStyleProperty(styles, side.cssWidth)) ?? 0;
305
+ const borderStyle = getStyleProperty(styles, side.cssStyle);
306
+ return width > 0 && borderStyle !== 'none' && borderStyle !== 'hidden';
307
+ }
308
+
309
+ function hasVisibleBorder(styles: CSSStyleDeclaration): boolean {
310
+ return BORDER_SIDE_PROPERTIES.some((side) => isVisibleBorderSide(styles, side));
311
+ }
312
+
313
+ function borderFrameKeyframe(
314
+ rect: LocalRect,
315
+ styles: CSSStyleDeclaration,
316
+ opacity: string,
317
+ ): Keyframe {
318
+ const frame: Keyframe = {
319
+ width: `${rect.width}px`,
320
+ height: `${rect.height}px`,
321
+ opacity,
322
+ transform: sharedElementTranslateTransform(rect, localTransform(styles)),
323
+ ...radiusKeyframe(styles),
324
+ };
325
+
326
+ for (const side of BORDER_SIDE_PROPERTIES) {
327
+ frame[side.width] = getStyleProperty(styles, side.cssWidth);
328
+ frame[side.color] = getStyleProperty(styles, side.cssColor);
329
+ }
330
+
331
+ return frame;
332
+ }
333
+
334
+ function appendBorderFrame(
335
+ wrapper: HTMLElement,
336
+ overlay: HTMLElement,
337
+ sourceStyles: CSSStyleDeclaration,
338
+ targetStyles: CSSStyleDeclaration,
339
+ rect: LocalRect,
340
+ ): HTMLElement {
341
+ if (!overlay.parentElement) wrapper.appendChild(overlay);
342
+
343
+ const frame = document.createElement('div');
344
+ Object.assign(frame.style, {
345
+ position: 'absolute',
346
+ left: '0',
347
+ top: '0',
348
+ width: `${rect.width}px`,
349
+ height: `${rect.height}px`,
350
+ margin: '0',
351
+ transformOrigin: 'top left',
352
+ pointerEvents: 'none',
353
+ boxSizing: 'border-box',
354
+ background: 'transparent',
355
+ });
356
+
357
+ for (const side of BORDER_SIDE_PROPERTIES) {
358
+ const styles = isVisibleBorderSide(sourceStyles, side) ? sourceStyles : targetStyles;
359
+ frame.style[side.style] = getStyleProperty(styles, side.cssStyle);
360
+ frame.style[side.width] = getStyleProperty(sourceStyles, side.cssWidth);
361
+ frame.style[side.color] = getStyleProperty(sourceStyles, side.cssColor);
362
+ }
363
+
364
+ overlay.appendChild(frame);
365
+ return frame;
366
+ }
367
+
240
368
  function hasVisualStyleChange(from: CSSStyleDeclaration, to: CSSStyleDeclaration): boolean {
241
369
  for (const prop of SHARED_ELEMENT_VISUAL_PROPERTIES) {
242
370
  if (getStyleProperty(from, prop) !== getStyleProperty(to, prop)) return true;
@@ -456,20 +584,40 @@ function runSharedElementTransition(
456
584
  const targetStyles = getComputedStyle(target);
457
585
  const fromOpacity = effectiveOpacity(source, outgoingLayer);
458
586
  const toOpacity = effectiveOpacity(target, incomingLayer);
587
+ const needsBorderFrame = hasVisibleBorder(sourceStyles) || hasVisibleBorder(targetStyles);
459
588
  const scaleX = to.width / from.width;
460
589
  const scaleY = to.height / from.height;
461
590
  const fromTransform = sharedElementTransform(from, 1, 1, localTransform(sourceStyles));
462
591
  const toTransform = sharedElementTransform(to, scaleX, scaleY, localTransform(targetStyles));
592
+
593
+ if (needsBorderFrame) {
594
+ hideBorderColors(clone);
595
+ const borderFrame = appendBorderFrame(wrapper, overlay, sourceStyles, targetStyles, from);
596
+ animations.push(
597
+ borderFrame.animate(
598
+ [
599
+ borderFrameKeyframe(from, sourceStyles, fromOpacity),
600
+ borderFrameKeyframe(to, targetStyles, toOpacity),
601
+ ],
602
+ sharedElementAnimationOptions(phase),
603
+ ),
604
+ );
605
+ }
606
+
463
607
  animations.push(
464
608
  clone.animate(
465
609
  [
466
610
  {
467
- ...visualStyleKeyframe(sourceStyles, fromOpacity),
611
+ ...visualStyleKeyframe(sourceStyles, fromOpacity, {
612
+ includeBorderColors: !needsBorderFrame,
613
+ }),
468
614
  ...radiusKeyframe(sourceStyles),
469
615
  transform: fromTransform,
470
616
  },
471
617
  {
472
- ...visualStyleKeyframe(targetStyles, toOpacity),
618
+ ...visualStyleKeyframe(targetStyles, toOpacity, {
619
+ includeBorderColors: !needsBorderFrame,
620
+ }),
473
621
  ...radiusKeyframe(targetStyles, scaleX, scaleY),
474
622
  transform: toTransform,
475
623
  },
@@ -16,7 +16,7 @@ import {
16
16
  } from '@dnd-kit/sortable';
17
17
  import { CSS } from '@dnd-kit/utilities';
18
18
  import { Copy, Grid2x2, ListOrdered, type LucideIcon, Sparkles, Trash2 } from 'lucide-react';
19
- import { Fragment, useEffect, useRef, useState } from 'react';
19
+ import { Fragment, useCallback, useEffect, useRef, useState } from 'react';
20
20
  import {
21
21
  ContextMenu,
22
22
  ContextMenuContent,
@@ -62,6 +62,9 @@ const DEFAULT_VERTICAL_THUMB_WIDTH = 184;
62
62
  const VERTICAL_RAIL_CHROME = 80;
63
63
  const MIN_VERTICAL_THUMB_WIDTH = 120;
64
64
  const HORIZONTAL_THUMB_HEIGHT = 64;
65
+ const VERTICAL_THUMB_PADDING_Y = 12;
66
+ const VERTICAL_THUMB_GAP = 8;
67
+ const VIRTUAL_OVERSCAN = 4;
65
68
 
66
69
  export function ThumbnailRail({
67
70
  pages,
@@ -89,9 +92,88 @@ export function ThumbnailRail({
89
92
  });
90
93
  }, [current]);
91
94
 
95
+ const thumbWidth =
96
+ width != null
97
+ ? Math.max(MIN_VERTICAL_THUMB_WIDTH, width - VERTICAL_RAIL_CHROME)
98
+ : DEFAULT_VERTICAL_THUMB_WIDTH;
99
+ const scale = thumbWidth / CANVAS_WIDTH;
100
+ const height = CANVAS_HEIGHT * scale;
101
+ const rowHeight = height + VERTICAL_THUMB_PADDING_Y + VERTICAL_THUMB_GAP;
102
+
103
+ const renderThumb = useCallback(
104
+ (PageComp: Page, i: number) => {
105
+ const active = i === current;
106
+ const inner = (
107
+ <ThumbContents
108
+ index={i}
109
+ total={pages.length}
110
+ active={active}
111
+ page={PageComp}
112
+ design={design}
113
+ scale={scale}
114
+ thumbWidth={thumbWidth}
115
+ height={height}
116
+ moduleTransition={moduleTransition}
117
+ />
118
+ );
119
+
120
+ const node = onReorder ? (
121
+ <SortableThumb
122
+ index={i}
123
+ active={active}
124
+ activeRef={active ? activeRef : undefined}
125
+ onSelect={() => onSelect(i)}
126
+ ariaLabel={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
127
+ >
128
+ {inner}
129
+ </SortableThumb>
130
+ ) : (
131
+ <button
132
+ type="button"
133
+ ref={active ? activeRef : undefined}
134
+ onClick={() => onSelect(i)}
135
+ aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
136
+ aria-current={active ? 'true' : undefined}
137
+ className={thumbButtonClass(active)}
138
+ >
139
+ {inner}
140
+ </button>
141
+ );
142
+
143
+ if (!actions) {
144
+ return <Fragment key={i}>{node}</Fragment>;
145
+ }
146
+ return (
147
+ <ThumbContextMenu
148
+ key={i}
149
+ index={i}
150
+ actions={actions}
151
+ pageCount={pages.length}
152
+ ariaLabel={format(t.thumbnailRail.pageActionsAria, { n: i + 1 })}
153
+ >
154
+ {node}
155
+ </ThumbContextMenu>
156
+ );
157
+ },
158
+ [
159
+ actions,
160
+ current,
161
+ design,
162
+ height,
163
+ moduleTransition,
164
+ onReorder,
165
+ onSelect,
166
+ pages.length,
167
+ scale,
168
+ thumbWidth,
169
+ t.thumbnailRail.goToPageAria,
170
+ t.thumbnailRail.pageActionsAria,
171
+ ],
172
+ );
173
+
92
174
  if (orientation === 'horizontal') {
93
175
  const scale = HORIZONTAL_THUMB_HEIGHT / CANVAS_HEIGHT;
94
- const width = CANVAS_WIDTH * scale;
176
+ const horizontalWidth = CANVAS_WIDTH * scale;
95
177
  return (
96
178
  <div className="bg-sidebar">
97
179
  <div className="overflow-x-auto overflow-y-hidden">
@@ -124,7 +206,7 @@ export function ThumbnailRail({
124
206
  ? 'border-brand shadow-[0_0_0_1px_var(--brand)]'
125
207
  : 'border-hairline group-hover/thumb:border-foreground/25',
126
208
  )}
127
- style={{ width, height: HORIZONTAL_THUMB_HEIGHT }}
209
+ style={{ width: horizontalWidth, height: HORIZONTAL_THUMB_HEIGHT }}
128
210
  >
129
211
  <SlideCanvas scale={scale} center={false} flat freezeMotion design={design}>
130
212
  <SlidePageProvider index={i} total={pages.length}>
@@ -154,68 +236,6 @@ export function ThumbnailRail({
154
236
  );
155
237
  }
156
238
 
157
- const thumbWidth =
158
- width != null
159
- ? Math.max(MIN_VERTICAL_THUMB_WIDTH, width - VERTICAL_RAIL_CHROME)
160
- : DEFAULT_VERTICAL_THUMB_WIDTH;
161
- const scale = thumbWidth / CANVAS_WIDTH;
162
- const height = CANVAS_HEIGHT * scale;
163
-
164
- const renderThumb = (PageComp: Page, i: number) => {
165
- const active = i === current;
166
- const inner = (
167
- <ThumbContents
168
- index={i}
169
- total={pages.length}
170
- active={active}
171
- page={PageComp}
172
- design={design}
173
- scale={scale}
174
- thumbWidth={thumbWidth}
175
- height={height}
176
- moduleTransition={moduleTransition}
177
- />
178
- );
179
-
180
- const node = onReorder ? (
181
- <SortableThumb
182
- index={i}
183
- active={active}
184
- activeRef={active ? activeRef : undefined}
185
- onSelect={() => onSelect(i)}
186
- ariaLabel={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
187
- >
188
- {inner}
189
- </SortableThumb>
190
- ) : (
191
- <button
192
- type="button"
193
- ref={active ? activeRef : undefined}
194
- onClick={() => onSelect(i)}
195
- aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
196
- aria-current={active ? 'true' : undefined}
197
- className={thumbButtonClass(active)}
198
- >
199
- {inner}
200
- </button>
201
- );
202
-
203
- if (!actions) {
204
- return <Fragment key={i}>{node}</Fragment>;
205
- }
206
- return (
207
- <ThumbContextMenu
208
- key={i}
209
- index={i}
210
- actions={actions}
211
- pageCount={pages.length}
212
- ariaLabel={format(t.thumbnailRail.pageActionsAria, { n: i + 1 })}
213
- >
214
- {node}
215
- </ThumbContextMenu>
216
- );
217
- };
218
-
219
239
  const list = (
220
240
  <aside className="flex flex-col gap-2 px-3 pb-3">
221
241
  <div className="-mx-3 sticky top-0 z-10 bg-sidebar px-4 pt-3 pb-1">
@@ -247,7 +267,13 @@ export function ThumbnailRail({
247
267
  </div>
248
268
  </div>
249
269
  </div>
250
- {pages.map(renderThumb)}
270
+ <VirtualThumbList
271
+ pages={pages}
272
+ current={current}
273
+ rowHeight={rowHeight}
274
+ activeRef={activeRef}
275
+ renderThumb={renderThumb}
276
+ />
251
277
  </aside>
252
278
  );
253
279
 
@@ -280,6 +306,137 @@ function thumbButtonClass(active: boolean): string {
280
306
  );
281
307
  }
282
308
 
309
+ function VirtualThumbList({
310
+ pages,
311
+ current,
312
+ rowHeight,
313
+ activeRef,
314
+ renderThumb,
315
+ }: {
316
+ pages: Page[];
317
+ current: number;
318
+ rowHeight: number;
319
+ activeRef: React.MutableRefObject<HTMLButtonElement | null>;
320
+ renderThumb: (page: Page, index: number) => React.ReactNode;
321
+ }) {
322
+ const rootRef = useRef<HTMLDivElement | null>(null);
323
+ const viewportRef = useRef<HTMLElement | null>(null);
324
+ const [range, setRange] = useState(() => getInitialVisibleRange(current, pages.length));
325
+
326
+ const updateRange = useCallback(() => {
327
+ const viewport = viewportRef.current;
328
+ const root = rootRef.current;
329
+ if (!viewport || !root) return;
330
+ const scrollTop = Math.max(0, viewport.scrollTop - root.offsetTop);
331
+ setRange(getVisibleRange(scrollTop, pages.length, viewport.clientHeight, rowHeight));
332
+ }, [pages.length, rowHeight]);
333
+
334
+ useEffect(() => {
335
+ const root = rootRef.current;
336
+ if (!root) return;
337
+ const viewport = root.closest('[data-slot="scroll-area-viewport"]') as HTMLElement | null;
338
+ if (!viewport) return;
339
+ viewportRef.current = viewport;
340
+
341
+ let frame = 0;
342
+ const scheduleUpdate = () => {
343
+ cancelAnimationFrame(frame);
344
+ frame = requestAnimationFrame(updateRange);
345
+ };
346
+ const resizeObserver = new ResizeObserver(scheduleUpdate);
347
+
348
+ viewport.addEventListener('scroll', scheduleUpdate, { passive: true });
349
+ resizeObserver.observe(viewport);
350
+ scheduleUpdate();
351
+
352
+ return () => {
353
+ cancelAnimationFrame(frame);
354
+ viewport.removeEventListener('scroll', scheduleUpdate);
355
+ resizeObserver.disconnect();
356
+ if (viewportRef.current === viewport) viewportRef.current = null;
357
+ };
358
+ }, [updateRange]);
359
+
360
+ useEffect(() => {
361
+ const viewport = viewportRef.current;
362
+ const root = rootRef.current;
363
+ if (!viewport || !root) return;
364
+
365
+ const top = root.offsetTop + current * rowHeight;
366
+ const bottom = top + rowHeight;
367
+ const viewportTop = viewport.scrollTop;
368
+ const viewportBottom = viewportTop + viewport.clientHeight;
369
+
370
+ if (top < viewportTop) {
371
+ viewport.scrollTo({ top, behavior: scrollBehavior() });
372
+ } else if (bottom > viewportBottom) {
373
+ viewport.scrollTo({ top: bottom - viewport.clientHeight, behavior: scrollBehavior() });
374
+ } else {
375
+ activeRef.current?.scrollIntoView({
376
+ block: 'nearest',
377
+ inline: 'nearest',
378
+ behavior: scrollBehavior(),
379
+ });
380
+ }
381
+ }, [activeRef, current, rowHeight]);
382
+
383
+ const visibleRange = clampVisibleRange(range, current, pages.length);
384
+ const visible = [];
385
+ for (let i = visibleRange.start; i < visibleRange.end; i++) {
386
+ visible.push(
387
+ <div
388
+ key={i}
389
+ className="absolute right-0 left-0"
390
+ style={{ top: i * rowHeight, height: rowHeight }}
391
+ >
392
+ {renderThumb(pages[i], i)}
393
+ </div>,
394
+ );
395
+ }
396
+
397
+ return (
398
+ <div ref={rootRef} className="relative" style={{ height: pages.length * rowHeight }}>
399
+ {visible}
400
+ </div>
401
+ );
402
+ }
403
+
404
+ type VisibleRange = { start: number; end: number };
405
+
406
+ function clampVisibleRange(range: VisibleRange, current: number, count: number): VisibleRange {
407
+ if (count <= 0) return { start: 0, end: 0 };
408
+ if (range.start >= 0 && range.start < count && range.start < range.end) {
409
+ return { start: range.start, end: Math.min(range.end, count) };
410
+ }
411
+ const clampedCurrent = Math.min(Math.max(current, 0), count - 1);
412
+ return getInitialVisibleRange(clampedCurrent, count);
413
+ }
414
+
415
+ function getVisibleRange(
416
+ scrollTop: number,
417
+ count: number,
418
+ viewportHeight: number,
419
+ rowHeight: number,
420
+ ): VisibleRange {
421
+ if (count <= 0) return { start: 0, end: 0 };
422
+ const visibleRows = Math.max(1, Math.ceil(viewportHeight / rowHeight));
423
+ const firstVisible = Math.min(count - 1, Math.max(0, Math.floor(scrollTop / rowHeight)));
424
+ const start = Math.max(0, firstVisible - VIRTUAL_OVERSCAN);
425
+ const end = Math.min(count, firstVisible + visibleRows + VIRTUAL_OVERSCAN + 1);
426
+ return { start, end };
427
+ }
428
+
429
+ function getInitialVisibleRange(current: number, count: number): VisibleRange {
430
+ if (count <= 0) return { start: 0, end: 0 };
431
+ const start = Math.max(0, current - VIRTUAL_OVERSCAN);
432
+ const end = Math.min(count, current + VIRTUAL_OVERSCAN + 1);
433
+ return { start, end };
434
+ }
435
+
436
+ function scrollBehavior(): ScrollBehavior {
437
+ return window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth';
438
+ }
439
+
283
440
  function ThumbContents({
284
441
  index,
285
442
  total,