@@ -179,23 +179,21 @@ export const LayoutSection = memo(function LayoutSection({
179179 // Commit X position (with auto-keyframe support)
180180 const handleXChange = useCallback (
181181 ( value : number ) => {
182- // Try auto-keyframe first for items with keyframes
183- let allHandled = true ;
184182 const autoOps : AutoKeyframeOperation [ ] = [ ] ;
183+ const fallbackItemIds : string [ ] = [ ] ;
185184 for ( const itemId of itemIds ) {
186185 const operation = getAutoKeyframeOperation ( itemId , 'x' , value ) ;
187186 if ( operation ) {
188187 autoOps . push ( operation ) ;
189188 } else {
190- allHandled = false ;
189+ fallbackItemIds . push ( itemId ) ;
191190 }
192191 }
193192 if ( autoOps . length > 0 ) {
194193 applyAutoKeyframeOperations ( autoOps ) ;
195194 }
196- // Fall back to base transform for items without keyframes
197- if ( ! allHandled ) {
198- onTransformChange ( itemIds , { x : value } ) ;
195+ if ( fallbackItemIds . length > 0 ) {
196+ onTransformChange ( fallbackItemIds , { x : value } ) ;
199197 }
200198 queueMicrotask ( ( ) => clearPreview ( ) ) ;
201199 } ,
@@ -217,21 +215,21 @@ export const LayoutSection = memo(function LayoutSection({
217215 // Commit Y position (with auto-keyframe support)
218216 const handleYChange = useCallback (
219217 ( value : number ) => {
220- let allHandled = true ;
221218 const autoOps : AutoKeyframeOperation [ ] = [ ] ;
219+ const fallbackItemIds : string [ ] = [ ] ;
222220 for ( const itemId of itemIds ) {
223221 const operation = getAutoKeyframeOperation ( itemId , 'y' , value ) ;
224222 if ( operation ) {
225223 autoOps . push ( operation ) ;
226224 } else {
227- allHandled = false ;
225+ fallbackItemIds . push ( itemId ) ;
228226 }
229227 }
230228 if ( autoOps . length > 0 ) {
231229 applyAutoKeyframeOperations ( autoOps ) ;
232230 }
233- if ( ! allHandled ) {
234- onTransformChange ( itemIds , { y : value } ) ;
231+ if ( fallbackItemIds . length > 0 ) {
232+ onTransformChange ( fallbackItemIds , { y : value } ) ;
235233 }
236234 queueMicrotask ( ( ) => clearPreview ( ) ) ;
237235 } ,
@@ -259,29 +257,29 @@ export const LayoutSection = memo(function LayoutSection({
259257 const handleWidthChange = useCallback (
260258 ( value : number ) => {
261259 const newHeight = aspectLocked && height !== 'mixed' ? Math . round ( value / currentAspectRatio ) : null ;
262-
263- let allHandled = true ;
264260 const autoOps : AutoKeyframeOperation [ ] = [ ] ;
261+ const fallbackUpdates = new Map < string , Partial < TransformProperties > > ( ) ;
265262 for ( const itemId of itemIds ) {
266263 const widthOperation = getAutoKeyframeOperation ( itemId , 'width' , value ) ;
267264 const heightOperation = newHeight !== null ? getAutoKeyframeOperation ( itemId , 'height' , newHeight ) : null ;
268- const widthHandled = Boolean ( widthOperation ) ;
269- const heightHandled = newHeight !== null ? Boolean ( heightOperation ) : true ;
270265 if ( widthOperation ) autoOps . push ( widthOperation ) ;
271266 if ( heightOperation ) autoOps . push ( heightOperation ) ;
272- if ( ! widthHandled || ! heightHandled ) {
273- allHandled = false ;
267+ const updates : Partial < TransformProperties > = { } ;
268+ if ( ! widthOperation ) {
269+ updates . width = value ;
270+ }
271+ if ( newHeight !== null && ! heightOperation ) {
272+ updates . height = newHeight ;
273+ }
274+ if ( Object . keys ( updates ) . length > 0 ) {
275+ fallbackUpdates . set ( itemId , updates ) ;
274276 }
275277 }
276278 if ( autoOps . length > 0 ) {
277279 applyAutoKeyframeOperations ( autoOps ) ;
278280 }
279- if ( ! allHandled ) {
280- if ( newHeight !== null ) {
281- onTransformChange ( itemIds , { width : value , height : newHeight } ) ;
282- } else {
283- onTransformChange ( itemIds , { width : value } ) ;
284- }
281+ if ( fallbackUpdates . size > 0 ) {
282+ updateItemsTransformMap ( fallbackUpdates , { operation : 'resize' } ) ;
285283 }
286284 queueMicrotask ( ( ) => clearPreview ( ) ) ;
287285 } ,
@@ -294,6 +292,7 @@ export const LayoutSection = memo(function LayoutSection({
294292 currentAspectRatio ,
295293 getAutoKeyframeOperation ,
296294 applyAutoKeyframeOperations ,
295+ updateItemsTransformMap ,
297296 ]
298297 ) ;
299298
@@ -318,29 +317,29 @@ export const LayoutSection = memo(function LayoutSection({
318317 const handleHeightChange = useCallback (
319318 ( value : number ) => {
320319 const newWidth = aspectLocked && width !== 'mixed' ? Math . round ( value * currentAspectRatio ) : null ;
321-
322- let allHandled = true ;
323320 const autoOps : AutoKeyframeOperation [ ] = [ ] ;
321+ const fallbackUpdates = new Map < string , Partial < TransformProperties > > ( ) ;
324322 for ( const itemId of itemIds ) {
325323 const heightOperation = getAutoKeyframeOperation ( itemId , 'height' , value ) ;
326324 const widthOperation = newWidth !== null ? getAutoKeyframeOperation ( itemId , 'width' , newWidth ) : null ;
327- const heightHandled = Boolean ( heightOperation ) ;
328- const widthHandled = newWidth !== null ? Boolean ( widthOperation ) : true ;
329325 if ( heightOperation ) autoOps . push ( heightOperation ) ;
330326 if ( widthOperation ) autoOps . push ( widthOperation ) ;
331- if ( ! heightHandled || ! widthHandled ) {
332- allHandled = false ;
327+ const updates : Partial < TransformProperties > = { } ;
328+ if ( ! heightOperation ) {
329+ updates . height = value ;
330+ }
331+ if ( newWidth !== null && ! widthOperation ) {
332+ updates . width = newWidth ;
333+ }
334+ if ( Object . keys ( updates ) . length > 0 ) {
335+ fallbackUpdates . set ( itemId , updates ) ;
333336 }
334337 }
335338 if ( autoOps . length > 0 ) {
336339 applyAutoKeyframeOperations ( autoOps ) ;
337340 }
338- if ( ! allHandled ) {
339- if ( newWidth !== null ) {
340- onTransformChange ( itemIds , { width : newWidth , height : value } ) ;
341- } else {
342- onTransformChange ( itemIds , { height : value } ) ;
343- }
341+ if ( fallbackUpdates . size > 0 ) {
342+ updateItemsTransformMap ( fallbackUpdates , { operation : 'resize' } ) ;
344343 }
345344 queueMicrotask ( ( ) => clearPreview ( ) ) ;
346345 } ,
@@ -353,6 +352,7 @@ export const LayoutSection = memo(function LayoutSection({
353352 currentAspectRatio ,
354353 getAutoKeyframeOperation ,
355354 applyAutoKeyframeOperations ,
355+ updateItemsTransformMap ,
356356 ]
357357 ) ;
358358
@@ -371,21 +371,21 @@ export const LayoutSection = memo(function LayoutSection({
371371 // Commit rotation (on mouse up, with auto-keyframe support)
372372 const handleRotationChange = useCallback (
373373 ( value : number ) => {
374- let allHandled = true ;
375374 const autoOps : AutoKeyframeOperation [ ] = [ ] ;
375+ const fallbackItemIds : string [ ] = [ ] ;
376376 for ( const itemId of itemIds ) {
377377 const operation = getAutoKeyframeOperation ( itemId , 'rotation' , value ) ;
378378 if ( operation ) {
379379 autoOps . push ( operation ) ;
380380 } else {
381- allHandled = false ;
381+ fallbackItemIds . push ( itemId ) ;
382382 }
383383 }
384384 if ( autoOps . length > 0 ) {
385385 applyAutoKeyframeOperations ( autoOps ) ;
386386 }
387- if ( ! allHandled ) {
388- onTransformChange ( itemIds , { rotation : value } ) ;
387+ if ( fallbackItemIds . length > 0 ) {
388+ onTransformChange ( fallbackItemIds , { rotation : value } ) ;
389389 }
390390 queueMicrotask ( ( ) => clearPreview ( ) ) ;
391391 } ,
0 commit comments