@@ -50,14 +50,21 @@ export function cssFontFamily(fontName: string): string {
5050 return FONT_FAMILY_MAP [ fontName ] ?? 'sans-serif' ;
5151}
5252
53- /** Build a CSS transform string combining rotation and mirror flips. */
54- export function layerTransform (
55- rotationDegrees : number ,
53+ /** Build a CSS transform string for rotation only.
54+ * Mirror flips are applied to inner content elements instead of the
55+ * LayerBox itself so that resize handles and labels stay in the correct
56+ * orientation. */
57+ export function layerTransform ( rotationDegrees : number ) : string | undefined {
58+ return rotationDegrees !== 0 ? `rotate(${ rotationDegrees } deg)` : undefined ;
59+ }
60+
61+ /** Build a CSS transform string for mirror flips, applied to content
62+ * elements (images, text) inside a layer box. */
63+ export function contentMirrorTransform (
5664 mirrorHorizontal : boolean ,
5765 mirrorVertical : boolean
5866) : string | undefined {
5967 const parts : string [ ] = [ ] ;
60- if ( rotationDegrees !== 0 ) parts . push ( `rotate(${ rotationDegrees } deg)` ) ;
6168 if ( mirrorHorizontal ) parts . push ( 'scaleX(-1)' ) ;
6269 if ( mirrorVertical ) parts . push ( 'scaleY(-1)' ) ;
6370 return parts . length > 0 ? parts . join ( ' ' ) : undefined ;
@@ -74,8 +81,6 @@ export function layerBoxStyle(
7481 opacity : number ;
7582 zIndex : number ;
7683 rotationDegrees : number ;
77- mirrorHorizontal : boolean ;
78- mirrorVertical : boolean ;
7984 borderColor : string ;
8085 bgColor : string ;
8186 outlineStyle ?: 'solid' | 'dashed' ;
@@ -87,7 +92,7 @@ export function layerBoxStyle(
8792 width,
8893 height,
8994 opacity : opts . visible ? opts . opacity : 0.2 ,
90- transform : layerTransform ( opts . rotationDegrees , opts . mirrorHorizontal , opts . mirrorVertical ) ,
95+ transform : layerTransform ( opts . rotationDegrees ) ,
9196 zIndex : opts . zIndex ,
9297 outline : `2px ${ opts . outlineStyle ?? 'solid' } ${ opts . borderColor } ` ,
9398 outlineOffset : '-2px' ,
@@ -153,8 +158,6 @@ export const VideoLayer: React.FC<{
153158 opacity : layer . opacity ,
154159 zIndex : layer . zIndex ,
155160 rotationDegrees : layer . rotationDegrees ,
156- mirrorHorizontal : layer . mirrorHorizontal ,
157- mirrorVertical : layer . mirrorVertical ,
158161 borderColor,
159162 bgColor,
160163 outlineStyle : layer . visible ? 'solid' : 'dashed' ,
@@ -256,8 +259,6 @@ export const TextOverlayLayer: React.FC<{
256259 opacity : overlay . opacity ,
257260 zIndex : overlay . zIndex ,
258261 rotationDegrees : overlay . rotationDegrees ,
259- mirrorHorizontal : overlay . mirrorHorizontal ,
260- mirrorVertical : overlay . mirrorVertical ,
261262 borderColor,
262263 bgColor,
263264 outlineStyle : 'dashed' ,
@@ -291,7 +292,14 @@ export const TextOverlayLayer: React.FC<{
291292 >
292293 { overlay . text }
293294 </ span >
294- < TextContent >
295+ < TextContent
296+ style = { {
297+ transform : contentMirrorTransform (
298+ overlay . mirrorHorizontal ,
299+ overlay . mirrorVertical
300+ ) ,
301+ } }
302+ >
295303 < span
296304 style = { {
297305 fontSize : overlay . fontSize ,
@@ -402,8 +410,6 @@ export const ImageOverlayLayer: React.FC<{
402410 opacity : overlay . opacity ,
403411 zIndex : overlay . zIndex ,
404412 rotationDegrees : overlay . rotationDegrees ,
405- mirrorHorizontal : overlay . mirrorHorizontal ,
406- mirrorVertical : overlay . mirrorVertical ,
407413 borderColor,
408414 bgColor,
409415 } ) }
@@ -421,6 +427,10 @@ export const ImageOverlayLayer: React.FC<{
421427 objectFit : 'contain' ,
422428 pointerEvents : 'none' ,
423429 opacity : 0.85 ,
430+ transform : contentMirrorTransform (
431+ overlay . mirrorHorizontal ,
432+ overlay . mirrorVertical
433+ ) ,
424434 } }
425435 />
426436 ) }
0 commit comments