Skip to content

Commit b04c5c7

Browse files
committed
more fixes
1 parent 877a996 commit b04c5c7

File tree

4 files changed

+16
-31
lines changed

4 files changed

+16
-31
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ function update_each_item_block(block, item, index, type) {
712712
// Handle each item animations
713713
const each_animation = block.a;
714714
if (transitions !== null && (type & EACH_KEYED) !== 0 && each_animation !== null) {
715-
each_animation(block, transitions, index, index_is_reactive);
715+
each_animation(block, transitions);
716716
}
717717
if (index_is_reactive) {
718718
set_signal_value(/** @type {import('./types.js').Signal<number>} */ (block.i), index);

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

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -665,26 +665,18 @@ function each_item_transition(transition) {
665665
*
666666
* @param {import('./types.js').EachItemBlock} block
667667
* @param {Set<import('./types.js').Transition>} transitions
668-
* @param {number} index
669-
* @param {boolean} index_is_reactive
670668
*/
671-
function each_item_animate(block, transitions, index, index_is_reactive) {
672-
let prev_index = block.i;
673-
if (index_is_reactive) {
674-
prev_index = /** @type {import('./types.js').Signal<number>} */ (prev_index).v;
675-
}
676-
if (prev_index !== index) {
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-
const type = transition.r;
682-
if (type === 'key') {
683-
transition.c();
684-
}
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();
685677
}
686-
schedule_raf_task(() => {
687-
trigger_transitions(transitions, 'key', from);
688-
});
689678
}
679+
schedule_raf_task(() => {
680+
trigger_transitions(transitions, 'key', from);
681+
});
690682
}

packages/svelte/src/internal/client/types.d.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,7 @@ export type EachBlock = {
288288

289289
export type EachItemBlock = {
290290
/** transition */
291-
a:
292-
| null
293-
| ((
294-
block: EachItemBlock,
295-
transitions: Set<Transition>,
296-
index: number,
297-
index_is_reactive: boolean
298-
) => void);
291+
a: null | ((block: EachItemBlock, transitions: Set<Transition>) => void);
299292
/** dom */
300293
d: null | TemplateNode | Array<TemplateNode>;
301294
/** effect */

packages/svelte/tests/runtime-legacy/samples/dynamic-element-animation/_config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export default test({
5353

5454
divs = target.querySelectorAll('div');
5555
assert.ok(~divs[0].style.transform);
56-
assert.equal(divs[1].style.transform, '');
57-
assert.equal(divs[2].style.transform, '');
58-
assert.equal(divs[3].style.transform, '');
56+
assert.equal(divs[1].style.transform, 'translate(1px, 0px)');
57+
assert.equal(divs[2].style.transform, 'translate(1px, 0px)');
58+
assert.equal(divs[3].style.transform, 'translate(1px, 0px)');
5959
assert.ok(~divs[4].style.transform);
6060

6161
raf.tick(100);

0 commit comments

Comments
 (0)