I am trying to implement multi-select feature using react-konva
. I found a multi-select sample code where I found transformer getClientRect()
method, but in the latest version and also in the documentation that method does not exist. I have done some changes in the aforementioned sample code which actually relies on transformer getClientRect()
method and it is working fine there but with the latest version that method is returning an object with all fields of value 0
.
Is there any other way to get the size of the transformer?
Thanks.
After digging into the Konva.Transformer
code, I figured out getX()
, getY()
, getWidth()
and getHeight()
methods. One can use these methods and create own getClientRect()
method as follows,
function getTransformerClientRect(
transformer: Konva.Transformer | null
): IRect {
if (!transformer) {
return {
x: 0,
y: 0,
width: 0,
height: 0,
};
}
return {
x: transformer.getX(),
y: transformer.getY(),
width: transformer.getWidth(),
height: transformer.getHeight(),
};
}