vaheqelyan / svelte-grid

A responsive, draggable and resizable grid layout, for Svelte. [NOT MAINTAINED]
https://svelte-grid.now.sh/
MIT License
970 stars 58 forks source link

Canvas size in component to follow parent cell #100

Closed j2l closed 3 years ago

j2l commented 3 years ago

Following your great solution using components in cells, I tried with canvas, but it doesn't follow the cell size: Here's Text.svelte:

<div>
    <canvas id="myCanvas"></canvas>
</div>

<style>
    canvas{
        border:1px solid #000000;
    }
</style>

By default, I have something not 100% and I would like it to be 100% of the cell. image

and when I resize the cell, it's not adapting to it: image

I tried forcing the canvas and the div sizes to 100% without luck.

I'm sure it will be a piece of cake for you to spot the problem :smile: Any idea?

vaheqelyan commented 3 years ago

i think you should specify width: 100% and height: 100%

<style>
  #canvas {
    width: 100%;
    height: 100%;
  }
</style>
j2l commented 3 years ago

I tried it and adding it on both canvas and div did the trick. Thank you very much @vaheqelyan!