jeudi 7 juin 2018

The height of html elements doesn't change

I have a little JavaScript / TypeScript problem. I have a file uploader for images and when the user uploads the image, it will be printed in a canvas. I want to change the canvas height after the image upload with JavaScript / TypeScript, but it doesn't changes.

function ZeichneBildInCanvas(): void {
  canvasBild.height = bild.height;
  canvasBild.width = bild.width;
  canvasBild.getContext("2d").drawImage(bild, 0, 0);

  canvasWrapper.setAttribute("height", canvasBild.style.height);
  canvasWrapper.style.height = canvasBild.style.height;

  ListeMitRechtecken[aktivesRechteck].canvas.width = bild.naturalWidth;
  ListeMitRechtecken[aktivesRechteck].canvas.height = bild.naturalHeight;
  ListeMitRechtecken[aktivesRechteck].context.drawImage(bild, 0, 0);
}

canvasWrapper and canvasBild don't change their heights. I tried it with .style.height and setAttributes, but I don't know why its not working.

Thank you for your support.




Aucun commentaire:

Enregistrer un commentaire