@@ -277,6 +277,8 @@ function reconcile_tracked_array(array, state, anchor, render_fn, flags, keys) {
277
277
278
278
/** @type {import('#client').Effect[] } */
279
279
var to_destroy = [ ] ;
280
+ /** @type {Array<import('#client').EachItem> } */
281
+ var to_animate = [ ] ;
280
282
281
283
// Step 1 — trim common suffix
282
284
while ( a > 0 && b > 0 && a_items [ a - 1 ] . k === keys [ b - 1 ] ) {
@@ -288,6 +290,10 @@ function reconcile_tracked_array(array, state, anchor, render_fn, flags, keys) {
288
290
if ( should_update ) {
289
291
update_item ( item , array [ b ] , b , flags ) ;
290
292
}
293
+ if ( is_animated ) {
294
+ item . a ?. measure ( ) ;
295
+ to_animate . push ( item ) ;
296
+ }
291
297
}
292
298
293
299
// Step 2 — trim common prefix
@@ -299,6 +305,10 @@ function reconcile_tracked_array(array, state, anchor, render_fn, flags, keys) {
299
305
if ( should_update ) {
300
306
update_item ( item , array [ start ] , start , flags ) ;
301
307
}
308
+ if ( is_animated ) {
309
+ item . a ?. measure ( ) ;
310
+ to_animate . push ( item ) ;
311
+ }
302
312
303
313
start += 1 ;
304
314
}
@@ -330,8 +340,6 @@ function reconcile_tracked_array(array, state, anchor, render_fn, flags, keys) {
330
340
map_set ( indexes , keys [ i ] , i ) ;
331
341
}
332
342
333
- /** @type {Array<import('#client').EachItem> } */
334
- var to_animate = [ ] ;
335
343
if ( is_animated ) {
336
344
// for all items that were in both the old and the new list,
337
345
// measure them and store them in `to_animate` so we can
@@ -395,20 +403,20 @@ function reconcile_tracked_array(array, state, anchor, render_fn, flags, keys) {
395
403
396
404
last_item = b_items [ b ] = item ;
397
405
}
406
+ }
398
407
399
- if ( to_animate . length > 0 ) {
400
- // TODO we need to briefly take any outroing elements out of the flow, so that
401
- // we can figure out the eventual destination of the animating elements
402
- // - https://github.com/sveltejs/svelte/pull/10798#issuecomment-2013681778
403
- // - https://svelte.dev/repl/6e891305e9644a7ca7065fa95c79d2d2?version=4.2.9
404
- effect ( ( ) => {
405
- untrack ( ( ) => {
406
- for ( item of to_animate ) {
407
- item . a ?. apply ( ) ;
408
- }
409
- } ) ;
408
+ if ( to_animate . length > 0 ) {
409
+ // TODO we need to briefly take any outroing elements out of the flow, so that
410
+ // we can figure out the eventual destination of the animating elements
411
+ // - https://github.com/sveltejs/svelte/pull/10798#issuecomment-2013681778
412
+ // - https://svelte.dev/repl/6e891305e9644a7ca7065fa95c79d2d2?version=4.2.9
413
+ effect ( ( ) => {
414
+ untrack ( ( ) => {
415
+ for ( item of to_animate ) {
416
+ item . a ?. apply ( ) ;
417
+ }
410
418
} ) ;
411
- }
419
+ } ) ;
412
420
}
413
421
414
422
pause_effects ( to_destroy , ( ) => {
0 commit comments