@waveform-playlist/ui-components 11.1.0 → 11.3.0
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 +10 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -899,9 +899,17 @@ var Channel = (props) => {
|
|
|
899
899
|
const { canvasRef, canvasMapRef } = useChunkedCanvasRefs();
|
|
900
900
|
const clipOriginX = useClipViewportOrigin();
|
|
901
901
|
const visibleChunkIndices = useVisibleChunkIndices(length, import_core.MAX_CANVAS_WIDTH, clipOriginX);
|
|
902
|
+
const dataVersionRef = (0, import_react4.useRef)(0);
|
|
903
|
+
const prevDataRef = (0, import_react4.useRef)(data);
|
|
904
|
+
if (prevDataRef.current !== data) {
|
|
905
|
+
dataVersionRef.current += 1;
|
|
906
|
+
prevDataRef.current = data;
|
|
907
|
+
}
|
|
908
|
+
const drawVersion = `${dataVersionRef.current}-${bits}-${waveHeight}-${devicePixelRatio}-${length}-${barWidth}-${barGap}-${drawMode}-${waveformColorToCss(waveOutlineColor)}-${waveformColorToCss(waveFillColor)}`;
|
|
902
909
|
(0, import_react4.useLayoutEffect)(() => {
|
|
903
910
|
const step = barWidth + barGap;
|
|
904
911
|
for (const [canvasIdx, canvas] of canvasMapRef.current.entries()) {
|
|
912
|
+
if (canvas.dataset.drawVersion === drawVersion) continue;
|
|
905
913
|
const globalPixelOffset = canvasIdx * import_core.MAX_CANVAS_WIDTH;
|
|
906
914
|
const ctx = canvas.getContext("2d");
|
|
907
915
|
const h2 = Math.floor(waveHeight / 2);
|
|
@@ -933,6 +941,7 @@ var Channel = (props) => {
|
|
|
933
941
|
}
|
|
934
942
|
}
|
|
935
943
|
}
|
|
944
|
+
canvas.dataset.drawVersion = drawVersion;
|
|
936
945
|
}
|
|
937
946
|
}
|
|
938
947
|
}, [
|
|
@@ -946,6 +955,7 @@ var Channel = (props) => {
|
|
|
946
955
|
length,
|
|
947
956
|
barWidth,
|
|
948
957
|
barGap,
|
|
958
|
+
drawVersion,
|
|
949
959
|
drawMode,
|
|
950
960
|
visibleChunkIndices,
|
|
951
961
|
index
|