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.js CHANGED
@@ -3969,6 +3969,33 @@ function Timeline({
3969
3969
  }
3970
3970
  }
3971
3971
  }, [pps, zoomStorageKey]);
3972
+ const fitPps = useCallback9((seconds) => {
3973
+ const el = scroller.current;
3974
+ if (!el || !(seconds > 0)) return null;
3975
+ const room = el.clientWidth - TL_HEAD_W - 48;
3976
+ if (room <= 0) return null;
3977
+ return clamp(room / seconds, TL_MIN_PPS, TL_MAX_PPS);
3978
+ }, []);
3979
+ const fit = useCallback9(() => {
3980
+ const v = fitPps(contentSeconds);
3981
+ if (v !== null) {
3982
+ setPps(v);
3983
+ if (scroller.current) scroller.current.scrollLeft = 0;
3984
+ }
3985
+ }, [fitPps, contentSeconds]);
3986
+ const fitted = useRef12(false);
3987
+ useLayoutEffect2(() => {
3988
+ if (fitted.current || !(contentSeconds > 0)) return;
3989
+ if (zoomStorageKey && typeof window !== "undefined" && window.localStorage.getItem(zoomStorageKey)) {
3990
+ fitted.current = true;
3991
+ return;
3992
+ }
3993
+ const v = fitPps(contentSeconds);
3994
+ if (v !== null) {
3995
+ fitted.current = true;
3996
+ setPps(v);
3997
+ }
3998
+ }, [contentSeconds, fitPps, zoomStorageKey]);
3972
3999
  useLayoutEffect2(() => {
3973
4000
  const a = anchor.current;
3974
4001
  if (!a || !scroller.current) return;
@@ -4141,6 +4168,18 @@ function Timeline({
4141
4168
  disabled: pps >= TL_MAX_PPS - 1e-6,
4142
4169
  children: "+"
4143
4170
  }
4171
+ ),
4172
+ /* @__PURE__ */ jsx25(
4173
+ "button",
4174
+ {
4175
+ type: "button",
4176
+ className: "rui-tl-zoombtn rui-tl-fit",
4177
+ "aria-label": "Fit to width",
4178
+ title: "Fit to width",
4179
+ onClick: fit,
4180
+ disabled: !(contentSeconds > 0),
4181
+ children: "\u2922"
4182
+ }
4144
4183
  )
4145
4184
  ] })
4146
4185
  ] });