Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
Reverse easing with the animation

I'm using the Element.animate() method to animate a side panel sliding into the page when it's opened. At closing time, the animation is reversed and then plays backwards. If the easing function is asymmetric the effect looks strange because the animation plain plays backwards, including each easing step. Using "ease-out" will start opening the panel quickly and slow down towards the end. But in reverse mode, it will start slowly and end quickly. This is not like simple CSS transitions IIRC, they apply the easing forwards in any direction.

I'd rather want all animations to start more quickly than they end, no matter the visual direction or their underlying implementation. Any animation should react swiftly and then ease out towards its final state.

Unfortunately I couldn't find a way to also reverse the easing function when reversing the animation. Is that even possible?

Here's some code:

// Open the panel
let keyframes = [{ left: "-200px" }, { left: "0" }];
let options = {
    duration: 1000,   // extra slow to see the difference
    easing: "ease-out",
    fill: "forwards"
};
let animation = panel.animate(keyframes, options);

// Close the panel
animation.reverse();
// Also want to reverse the easing here, but how?

I'm using the reverse() method because the closing may also start while the opening is still ongoing (and vice versa). If somebody pushes the menu button quickly (or another app event occurs), then the new animation must begin immediately, without first cancelling the current one and resetting (jumping) the panel position to either end state. All changes in direction must be seamless (like in real world physics where things usually cannot suddenly jump, too).

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda