File tree 2 files changed +15
-6
lines changed
2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -278,17 +278,22 @@ pub fn flex_node_system(
278
278
to_logical ( layout. size . width ) ,
279
279
to_logical ( layout. size . height ) ,
280
280
) ;
281
+ // only trigger change detection when the new value is different
281
282
if node. size != new_size {
282
283
node. size = new_size;
283
284
}
284
- let position = & mut transform. translation ;
285
- position . x = to_logical ( layout. location . x + layout. size . width / 2.0 ) ;
286
- position . y = to_logical ( layout. location . y + layout. size . height / 2.0 ) ;
285
+ let mut new_position = transform. translation ;
286
+ new_position . x = to_logical ( layout. location . x + layout. size . width / 2.0 ) ;
287
+ new_position . y = to_logical ( layout. location . y + layout. size . height / 2.0 ) ;
287
288
if let Some ( parent) = parent {
288
289
if let Ok ( parent_layout) = flex_surface. get_layout ( parent. 0 ) {
289
- position . x -= to_logical ( parent_layout. size . width / 2.0 ) ;
290
- position . y -= to_logical ( parent_layout. size . height / 2.0 ) ;
290
+ new_position . x -= to_logical ( parent_layout. size . width / 2.0 ) ;
291
+ new_position . y -= to_logical ( parent_layout. size . height / 2.0 ) ;
291
292
}
292
293
}
294
+ // only trigger change detection when the new value is different
295
+ if transform. translation != new_position {
296
+ transform. translation = new_position;
297
+ }
293
298
}
294
299
}
Original file line number Diff line number Diff line change @@ -45,7 +45,11 @@ fn update_hierarchy(
45
45
) -> f32 {
46
46
current_global_z += UI_Z_STEP ;
47
47
if let Ok ( mut transform) = node_query. get_mut ( entity) {
48
- transform. translation . z = current_global_z - parent_global_z;
48
+ let new_z = current_global_z - parent_global_z;
49
+ // only trigger change detection when the new value is different
50
+ if transform. translation . z != new_z {
51
+ transform. translation . z = new_z;
52
+ }
49
53
}
50
54
if let Ok ( children) = children_query. get ( entity) {
51
55
let current_parent_global_z = current_global_z;
You can’t perform that action at this time.
0 commit comments