@@ -21,7 +21,7 @@ import {
2121 managed_effect ,
2222 managed_pre_effect ,
2323 mark_subtree_inert ,
24- schedule_microtask ,
24+ schedule_raf_task ,
2525 untrack
2626} from './runtime.js' ;
2727import { raf } from './timing.js' ;
@@ -646,7 +646,8 @@ function each_item_transition(transition) {
646646 transitions . delete ( transition ) ;
647647 if ( transition . r !== 'key' ) {
648648 for ( let other of transitions ) {
649- if ( other . r === 'key' || other . r === 'in' ) {
649+ const type = other . r ;
650+ if ( type === 'key' || type === 'in' ) {
650651 transitions . delete ( other ) ;
651652 }
652653 }
@@ -664,26 +665,18 @@ function each_item_transition(transition) {
664665 *
665666 * @param {import('./types.js').EachItemBlock } block
666667 * @param {Set<import('./types.js').Transition> } transitions
667- * @param {number } index
668- * @param {boolean } index_is_reactive
669668 */
670- function each_item_animate ( block , transitions , index , index_is_reactive ) {
671- let prev_index = block . i ;
672- if ( index_is_reactive ) {
673- prev_index = /** @type {import('./types.js').Signal<number> } */ ( prev_index ) . v ;
674- }
675- const items = block . p . v ;
676- if ( prev_index !== index && /** @type {number } */ ( index ) < items . length ) {
677- const from_dom = /** @type {Element } */ ( get_first_element ( block ) ) ;
678- const from = from_dom . getBoundingClientRect ( ) ;
679- // Cancel any existing key transitions
680- for ( const transition of transitions ) {
681- if ( transition . r === 'key' ) {
682- transition . c ( ) ;
683- }
669+ function each_item_animate ( block , transitions ) {
670+ const from_dom = /** @type {Element } */ ( get_first_element ( block ) ) ;
671+ const from = from_dom . getBoundingClientRect ( ) ;
672+ // Cancel any existing key transitions
673+ for ( const transition of transitions ) {
674+ const type = transition . r ;
675+ if ( type === 'key' ) {
676+ transition . c ( ) ;
684677 }
685- schedule_microtask ( ( ) => {
686- trigger_transitions ( transitions , 'key' , from ) ;
687- } ) ;
688678 }
679+ schedule_raf_task ( ( ) => {
680+ trigger_transitions ( transitions , 'key' , from ) ;
681+ } ) ;
689682}
0 commit comments