// First: measure the starting position before changing the layout
const first = el.getBoundingClientRect();
// Last: apply the CSS class that establishes the final position
el.classList.add("세상-끝의-라멘");
const last = el.getBoundingClientRect(); // Measuring immediately after the change may trigger synchronous layout
// Invert: calculate the offset from the final position back to the start
const invert = first.top - last.top;
// Play: make it appear at the starting position with the first keyframe, then remove the offset
// The layout is already final; only transform changes during playback
const player = el.animate(
[
{ transform: `translateY(${invert}px)` },
{ transform: "translateY(0)" },
],
{
duration: 300,
easing: "cubic-bezier(0,0,0.32,1)",
},
);
aerotwist.comFLIP Your AnimationsAnimations in your web app should run at 60fps. Not always easy to achieve that,and it really depends on what you're trying to do, but I'm here to help. With FLIP.MDN Web DocsWeb Animations API - Web APIs | MDNThe Web Animations API allows for synchronizing and timing changes to the presentation of a Web page, i.e., animation of DOM elements. It does so by combining two models: the Timing Model and the Animation Model.