Apply suggestions from code review

pull/16035/head
Rich Harris 4 months ago committed by GitHub
parent 2188cd083b
commit 9dc4c2cf63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2,4 +2,4 @@
'svelte': patch 'svelte': patch
--- ---
fix: transitions might render animated elements without animation styles applied for the duration of some rendering frames when they start fix: use `fill: 'forwards'` on transition animations to prevent flicker

@ -382,14 +382,12 @@ function animate(element, options, counterpart, t2, on_finish) {
// multiplier is in effect). in the common case that it is `0`, we keep it anyway so that // multiplier is in effect). in the common case that it is `0`, we keep it anyway so that
// the CSS keyframes aren't created until the DOM is updated // the CSS keyframes aren't created until the DOM is updated
// //
// fill forwards to prevent the element to render without animation styles applied // fill forwards to prevent the element from rendering without styles applied
// when entering the onfinish callback, can be verified by adding a breakpoint in the onfinish callback
// see https://github.com/sveltejs/svelte/issues/14732 // see https://github.com/sveltejs/svelte/issues/14732
var animation = element.animate(keyframes, { duration: delay, fill: 'forwards' }); var animation = element.animate(keyframes, { duration: delay, fill: 'forwards' });
animation.onfinish = () => { animation.onfinish = () => {
// have to manually cancel the dummy animation to remove it from the animations stack // remove dummy animation from the stack to prevent conflict with main animation
// because it fill forwards
animation.cancel(); animation.cancel();
// for bidirectional transitions, we start from the current position, // for bidirectional transitions, we start from the current position,

Loading…
Cancel
Save