reifyui 0.9.0 → 0.9.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.cjs +39 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/timeline/Timeline.jsx +30 -0
- package/styles/timeline.css +4 -1
package/dist/index.cjs
CHANGED
|
@@ -4208,6 +4208,33 @@ function Timeline({
|
|
|
4208
4208
|
}
|
|
4209
4209
|
}
|
|
4210
4210
|
}, [pps, zoomStorageKey]);
|
|
4211
|
+
const fitPps = (0, import_react26.useCallback)((seconds) => {
|
|
4212
|
+
const el = scroller.current;
|
|
4213
|
+
if (!el || !(seconds > 0)) return null;
|
|
4214
|
+
const room = el.clientWidth - TL_HEAD_W - 48;
|
|
4215
|
+
if (room <= 0) return null;
|
|
4216
|
+
return clamp(room / seconds, TL_MIN_PPS, TL_MAX_PPS);
|
|
4217
|
+
}, []);
|
|
4218
|
+
const fit = (0, import_react26.useCallback)(() => {
|
|
4219
|
+
const v = fitPps(contentSeconds);
|
|
4220
|
+
if (v !== null) {
|
|
4221
|
+
setPps(v);
|
|
4222
|
+
if (scroller.current) scroller.current.scrollLeft = 0;
|
|
4223
|
+
}
|
|
4224
|
+
}, [fitPps, contentSeconds]);
|
|
4225
|
+
const fitted = (0, import_react26.useRef)(false);
|
|
4226
|
+
(0, import_react26.useLayoutEffect)(() => {
|
|
4227
|
+
if (fitted.current || !(contentSeconds > 0)) return;
|
|
4228
|
+
if (zoomStorageKey && typeof window !== "undefined" && window.localStorage.getItem(zoomStorageKey)) {
|
|
4229
|
+
fitted.current = true;
|
|
4230
|
+
return;
|
|
4231
|
+
}
|
|
4232
|
+
const v = fitPps(contentSeconds);
|
|
4233
|
+
if (v !== null) {
|
|
4234
|
+
fitted.current = true;
|
|
4235
|
+
setPps(v);
|
|
4236
|
+
}
|
|
4237
|
+
}, [contentSeconds, fitPps, zoomStorageKey]);
|
|
4211
4238
|
(0, import_react26.useLayoutEffect)(() => {
|
|
4212
4239
|
const a = anchor.current;
|
|
4213
4240
|
if (!a || !scroller.current) return;
|
|
@@ -4380,6 +4407,18 @@ function Timeline({
|
|
|
4380
4407
|
disabled: pps >= TL_MAX_PPS - 1e-6,
|
|
4381
4408
|
children: "+"
|
|
4382
4409
|
}
|
|
4410
|
+
),
|
|
4411
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4412
|
+
"button",
|
|
4413
|
+
{
|
|
4414
|
+
type: "button",
|
|
4415
|
+
className: "rui-tl-zoombtn rui-tl-fit",
|
|
4416
|
+
"aria-label": "Fit to width",
|
|
4417
|
+
title: "Fit to width",
|
|
4418
|
+
onClick: fit,
|
|
4419
|
+
disabled: !(contentSeconds > 0),
|
|
4420
|
+
children: "\u2922"
|
|
4421
|
+
}
|
|
4383
4422
|
)
|
|
4384
4423
|
] })
|
|
4385
4424
|
] });
|