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

71
Visualizações
Styling linked to attribute not being executed immediately after new attribute is set gridstack

Why do i need to setTimeOut after setting attribute to my div element(chartNode),that belongs under gridstack, which will then change it's css styling, more specifically it's position on the x & y axis in the gridstack, otherwise it will proceed to execute the domToImage.toPng() before the new CSS styling has taken effect.

Question

How do I replace setTimeOut with a more appropriate event handler that waits for the new attribute to be set and new css to be applied before executing domToImage.ToPng?

Code

 let node = document.getElementsByClassName('view-container view-grid-' + view_id[1])[0];
                    // const data = await convertToPng(doc,node,doc_width,doc_height,doc_wh_ratio);

                    let chartNode =  node.querySelectorAll('[gs-id="view1111|mod15"]')[0];
                    chartNode.setAttribute('gs-x',0);
                    chartNode.setAttribute('gs-y',0);
                    console.log(chartNodes);
                    setTimeout(async function () {
                        let dataUrl = await (domtoimage.toPng(chartNode));
                        console.log(dataUrl);
                    }, 1000);
about 4 years ago · Santiago Trujillo
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