Skip to content

Commit a4dc4dd

Browse files
committed
Update tests
1 parent 3ab3895 commit a4dc4dd

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ function create_transition(dom, init, direction, effect) {
438438
if (needs_reverse) {
439439
const payload = transition.p;
440440
const current_animation = /** @type {Animation} */ (animation);
441+
// If we are working with CSS animations, then before we call reverse, we also need to ensure
442+
// that we reverse the easing logic. To do this we need to re-create the keyframes so they're
443+
// in reverse with easing properly reversed too.
441444
if (
442445
payload !== null &&
443446
payload.css !== undefined &&

packages/svelte/tests/animation-helpers.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ class Animation {
5353
this.onfinish = () => {};
5454
this.pending = true;
5555
this.currentTime = 0;
56+
this.playState = 'running';
57+
this.effect = {
58+
setKeyframes: (/** @type {Keyframe[]} */ keyframes) => {
59+
this.#keyframes = keyframes;
60+
}
61+
};
5662
}
5763

5864
play() {
5965
this.#paused = false;
6066
raf.animations.add(this);
67+
this.playState = 'running';
6168
this._update();
6269
}
6370

@@ -107,6 +114,7 @@ class Animation {
107114
if (this.#reversed) {
108115
raf.animations.delete(this);
109116
}
117+
this.playState = 'idle';
110118
}
111119

112120
cancel() {
@@ -118,11 +126,13 @@ class Animation {
118126

119127
pause() {
120128
this.#paused = true;
129+
this.playState = 'paused';
121130
}
122131

123132
reverse() {
124133
this.#timeline_offset = this.currentTime;
125134
this.#reversed = !this.#reversed;
135+
this.playState = 'running';
126136
}
127137
}
128138

packages/svelte/tests/runtime-legacy/samples/class-shortcut-with-transition/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default test({
1818
raf.tick(150);
1919
assert.htmlEqual(
2020
target.innerHTML,
21-
'<p>foo</p><p class="red svelte-1yszte8 border" style="overflow: hidden; opacity: 0; border-top-width: 3.4999399975999683px; border-bottom-width: 3.4999399975999683px;">bar</p>'
21+
'<p>foo</p><p class="red svelte-1yszte8 border" style="overflow: hidden; opacity: 0; border-top-width: 0.5000600024000317px; border-bottom-width: 0.5000600024000317px;">bar</p>'
2222
);
2323
component.open = true;
2424
raf.tick(250);

0 commit comments

Comments
 (0)