I have one function which sets class variable to Konva.Stage and I want to add event listener to this variable in same function. But unfortunately I cannot access other class functions and variables in this event listener. Basically, I cannot access to "this". How can I solve this problem?
Here you can see my example
setStage = () => {
this.stage = new Konva.Stage({
container: 'imageCanvas',
width: this.plt.width(),
height: this.plt.height(),
listening: true
});
this.stage.on('tap', function(evt) {
console.log("TAP TRIGGERED");
// set active shape
var shape = evt.target;
this.activeShape = this.activeShape && this.activeShape.getName() === shape.getName() ? null : shape;
// <------ CANNOT ACCESS this.activeShape
this.baseLayer.draw(); //<------ CANNOT ACCESS this.baseLayer
};
}