Set layer width on Konva js

1.8k views Asked by At

On KnovaJS, how can I set the width and height of a layer?

http://konvajs.github.io/api/Konva.Layer.html

I tried:

var layer = new Konva.Layer({x: 100, y: 200, width: 500, height: 500});

Only x and y properties work.

1

There are 1 answers

0
pgrodrigues On BEST ANSWER

According to Konvajs documentation, both width() and height() are getters/setters. However for layers in particular, the getter will return the stage width/height and if you want to set the width/height, you should use stage.width(500); and stage.height(500);, respectively.