I have a rectangle which I want to be responsive according to the width.
Currently, my logic is straight-forward:
aspectRatio = 16 / 9
win = {
width: window.innerWidth,
height: window.innerHeight,
}
get browser() {
const width = this.win.width - 250
const height = width / this.aspectRatio
return {
width,
height,
}
}
I calculate my width by subtracting sidebar width which is 250 from win.width.
And for my height, I divide width by aspectRatio.
However, this results in 0 height when I reduce my window size to ~700px.
My application looks like:
Demo → https://gqhhl.csb.app/
CodeSandBox → https://codesandbox.io/s/add-padding-to-centered-canvas-with-sidebar-gqhhl
What I really want is for that papayawhip rectangle to be responsive. I'm not sure which algorithm to use? I'm using Canvas using KonvaJS but the logic is in JavaScript.
How do I make it responsive & proportional? Currently, the height gets shortened very quick.
