Update
This commit is contained in:
@@ -224,11 +224,17 @@ const useVideoExport = ({ timelineElements, dimensions, totalDuration, watermark
|
||||
opacity: WATERMARK_CONFIG.opacity,
|
||||
align: 'center',
|
||||
verticalAlign: 'middle',
|
||||
offsetX: 90, // Approximate half-width to center the text
|
||||
offsetY: 5, // Approximate half-height to center the text
|
||||
});
|
||||
|
||||
layer.add(watermarkText);
|
||||
|
||||
// Force text measurement and update offset for proper centering
|
||||
watermarkText._setTextData();
|
||||
const textWidth = watermarkText.width();
|
||||
const textHeight = watermarkText.height();
|
||||
watermarkText.offsetX(textWidth / 2);
|
||||
watermarkText.offsetY(textHeight / 2);
|
||||
|
||||
layer.draw();
|
||||
|
||||
const dataURL = stage.toDataURL({
|
||||
|
||||
@@ -331,6 +331,22 @@ const VideoPreview = ({
|
||||
{watermarked && (
|
||||
<Text
|
||||
key={`watermark-${fontsLoaded}`}
|
||||
ref={(node) => {
|
||||
if (node && fontsLoaded) {
|
||||
// Force text measurement after font loading
|
||||
setTimeout(() => {
|
||||
node._setTextData();
|
||||
// Update offset to properly center the text
|
||||
const textWidth = node.width();
|
||||
const textHeight = node.height();
|
||||
node.offsetX(textWidth / 2);
|
||||
node.offsetY(textHeight / 2);
|
||||
if (layerRef.current) {
|
||||
layerRef.current.batchDraw();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
}}
|
||||
text="memefa.st"
|
||||
x={dimensions.width / 2}
|
||||
y={dimensions.height / 2 + dimensions.height * 0.2}
|
||||
@@ -342,8 +358,6 @@ const VideoPreview = ({
|
||||
opacity={WATERMARK_CONFIG.opacity}
|
||||
align="center"
|
||||
verticalAlign="middle"
|
||||
offsetX={90} // Approximate half-width to center the text
|
||||
offsetY={5} // Approximate half-height to center the text
|
||||
draggable={false}
|
||||
listening={false} // Prevents any mouse interactions
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user