Skip to content

Commit 6619b8c

Browse files
committed
fix: improve animation heuristics
better fix better fix
1 parent 05789da commit 6619b8c

File tree

1 file changed

+12
-15
lines changed
  • packages/svelte/src/internal/client

1 file changed

+12
-15
lines changed

packages/svelte/src/internal/client/each.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
mutable_source,
2626
push_destroy_fn,
2727
render_effect,
28-
schedule_task,
2928
set_signal_value,
3029
source
3130
} from './runtime.js';
@@ -486,6 +485,17 @@ function reconcile_tracked_array(
486485
key = is_computed_key ? keys[a] : item;
487486
map_set(item_index, key, a);
488487
}
488+
// If keys are animated, we need to do updates before actual moves
489+
if (is_animated) {
490+
for (b = start; b <= a_end; ++b) {
491+
a = map_get(item_index, /** @type {V} */ (a_blocks[b].k));
492+
if (a !== undefined) {
493+
item = array[a];
494+
block = a_blocks[b];
495+
update_each_item_block(block, item, a, flags);
496+
}
497+
}
498+
}
489499
for (b = start; b <= a_end; ++b) {
490500
a = map_get(item_index, /** @type {V} */ (a_blocks[b].k));
491501
block = a_blocks[b];
@@ -501,22 +511,9 @@ function reconcile_tracked_array(
501511
if (pos === MOVED_BLOCK) {
502512
mark_lis(sources);
503513
}
504-
// If keys are animated, we need to do updates before actual moves
505-
var should_create;
506-
if (is_animated) {
507-
var i = b_length;
508-
while (i-- > 0) {
509-
b_end = i + start;
510-
a = sources[i];
511-
if (pos === MOVED_BLOCK) {
512-
block = b_blocks[b_end];
513-
item = array[b_end];
514-
update_each_item_block(block, item, b_end, flags);
515-
}
516-
}
517-
}
518514
var last_block;
519515
var last_sibling;
516+
var should_create;
520517
while (b_length-- > 0) {
521518
b_end = b_length + start;
522519
a = sources[b_length];

0 commit comments

Comments
 (0)