@ai-matrx/canvas 0.7.1 → 0.7.2
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/CHANGELOG.md +11 -0
- package/dist/react.cjs +19 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +19 -4
- package/dist/react.js.map +1 -1
- package/dist/styles.css +14 -9
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -3154,15 +3154,30 @@ function TabStrip({ tabs, activeItemId }) {
|
|
|
3154
3154
|
const canvas = useCanvas();
|
|
3155
3155
|
const strip = useRef7(null);
|
|
3156
3156
|
const [width, setWidth] = useState5(0);
|
|
3157
|
+
const read = useRef7(() => {
|
|
3158
|
+
});
|
|
3157
3159
|
useIsoLayoutEffect4(() => {
|
|
3158
3160
|
const el = strip.current;
|
|
3159
3161
|
if (!el) return void 0;
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3162
|
+
let live = true;
|
|
3163
|
+
const measure = () => {
|
|
3164
|
+
if (live) setWidth(Math.floor(el.getBoundingClientRect().width));
|
|
3165
|
+
};
|
|
3166
|
+
read.current = measure;
|
|
3167
|
+
measure();
|
|
3168
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
3163
3169
|
observer?.observe(el);
|
|
3164
|
-
|
|
3170
|
+
void document.fonts?.ready?.then(measure);
|
|
3171
|
+
const frame2 = typeof requestAnimationFrame === "undefined" ? 0 : requestAnimationFrame(() => requestAnimationFrame(measure));
|
|
3172
|
+
return () => {
|
|
3173
|
+
live = false;
|
|
3174
|
+
observer?.disconnect();
|
|
3175
|
+
if (frame2 && typeof cancelAnimationFrame !== "undefined") cancelAnimationFrame(frame2);
|
|
3176
|
+
};
|
|
3165
3177
|
}, []);
|
|
3178
|
+
useIsoLayoutEffect4(() => {
|
|
3179
|
+
read.current();
|
|
3180
|
+
}, [tabs.length]);
|
|
3166
3181
|
const activeIndex = Math.max(0, tabs.findIndex((tab) => tab.itemId === activeItemId));
|
|
3167
3182
|
const fit = fitCanvasTabs(tabs.length, activeIndex, width);
|
|
3168
3183
|
const shown = tabs.slice(fit.start, fit.end);
|