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

129
Visualizações
dom-to-image images not rendered

I have a div with two divs inside, each one with a background image. When I render, the images are not displayed, but If I try a second time (and any subsequent time) the images will be displayed. One of the two is quite large (1200x800), the other is 400x300. How can I load them before the first render?

.board-overlay {
background: url('/img/homebrew/board/overlay-faction-board.png') left top no-repeat;
width: 100%;
height: 100%;
z-index: 2;
}

.board-avatar-image{
background: url('/img/homebrew/board/avatar-1.jpg') left 25px no-repeat;
width: 489px;
height: 300px;
position: absolute;
z-index: 1;
}

I tried with a timeout:

  buttonSave.addEventListener('click', () => {
      var node = document.getElementById('capture');
      buttonSave.innerHTML = "<i class='fas fa-spinner fa-pulse mr-2'></i> Rendering...";

      setTimeout(() => {
        domtoimage.toBlob(node, {
          quality: 0.99,
          width: node.clientWidth * 2,
          height: node.clientHeight * 2,
          style: {
            transform: 'scale(2)',
            transformOrigin: 'top left'
          }
        }).then(canvas => {
          buttonSave.innerHTML = "<i class='fas fa-image mr-2'></i> Save as Image";
          var fileName = '-loyalty-card.png';
          saveAs(canvas, fileName);
        });
      }, 300);

    });

I tried this.shot_loading = true; but without significant benefits.

I also tried to use a <img> instead of background image but it doesn't get rendered

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