E
E
Egorian2018-08-17 15:56:07
JavaScript
Egorian, 2018-08-17 15:56:07

Konvajs. How to get object on click?

I work with konva
I have an array of squares of this type

let square= new Konva.Rect({
              x:cur_x,
              y:cur_y,
              width:seg_size,
              height:seg_size,
              stroke:"black",
              fill:"green",
              name:"rect"
          });

I get them all like this: Now, when I click on one of the squares, I need to get its position. I do sovar s=stage.find(".rect");
s.on("click",()=>{
   console.log(this.getClientRect().x)
});

But I get How to get the position of an element in an array? TypeError: this.getClientRect is not a function.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2018-08-17
@Sanasol

getClientRects

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question