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

109
Visualizações
Konva.js: simultaneously run tweens look out of sync

Here's the situation. I have a collection of nodes and need them to move up and then back down. For this I am using Konva.Tween as in the demo. As you can see, I create and run tweens in a for loop. What I want is all squares to move in sync, but it looks like some of them are moving altogether, but some of them are gone mad and moving with a delay or something. And the interesting part is, if you click the GO button many times, you will see that it's the same squares which go out of sync, not random ones, so this is something persistent.

What am I doing wrong and is there a correct way to implement what I need?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Add them to a Konva.Group and then run the tween on the group. You can add them to the group when they are created or you can rect.moveTo(group) [OR group.add(rect)] just before you need to tween them.

var tweenGroup = new Konva.Group();
layer.add(tweenGroup);

document.getElementById('go').addEventListener('click', () => {
    const durationSec = 0.3;
    for (const r of rects) {
        tweenGroup.add(r);
    }
    new Konva.Tween({
        node: tweenGroup,
        y: 70,
        duration: durationSec / 2,
        onFinish: function() {
            new Konva.Tween({
                node: tweenGroup,
                y: 100,
                duration: durationSec / 2
            }).play();
        }
    }).play();
})

Here is the updated codepen with them moving in sync. https://codepen.io/richardjonlewis/pen/VwrGqNN

about 4 years ago · Juan Pablo Isaza Relatório
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