I want to set the height and width of the Konva based on the width of its parent container. As I was using static value for the stage which is
stageConfiguration:{ height: innerWidth * .5, width:innerWidth * 0.5}
And have to refresh every time I resize the screen. Is there a way to set the dynamic height and width to stageConfiguration. Current I am stuck on this and looking for a way to set dynamic height and width.
<template>
<div class="konvaContainer">
<v-stage :config="stageConfiguration" >
<v-layer>
</v-layer>
</v-stage>
</div>
</template>
<script>
export default {
components: {
Loading
},
data: () => ({
stageConfiguration: {}
)},
methods:
{
responsiveStage : function() {
var container = document.querySelector('.konvaContainer');
var width = container.clientWidth;
const stageWidth= width*.5;
const stageHeight= width *.5;
this.stageConfiguration ={
width:stageWidth,
height:stageHeight
}
}}
}
</script>