javascript - Event delegation in KineticJS -


i'm wondering if possible create event delegation object reference inside object, scenario.

i have 2 circles , 1 line between 2 circles, every time circle changes own postition have update line's position well, time have created custom line going have reference 2 circles properties (origin, target) isn't binding event in way.

what i'm tryting like>

this.origin.on('dragstart dragmove',function(){     console.log("origin mouse move");     this.setpoints([origin.getx(),origin.gety(), target.getx(), target.gety()]);     this.draw(); }); 

this fiddle

buildarrow: function(origin,target){     var arrowinstance = new shape.arrow({        points: [origin.getx(),origin.gety(), target.getx(), target.gety()],         stroke: '#629dd1',         tension: 1     });     arrowinstance.origin=origin;     origin.line = arrowinstance;      arrowinstance.target=target;     target.line = arrowinstance;     return arrowinstance; }, updateposition : function() {     this.points([this.origin.getx(),this.origin.gety(), this.target.getx(), this.target.gety()]); }, 

then:

this.on('dragstart dragmove',function(){     var centerpoint = (this.cellsize/2)      this.setx(((math.round(this.getx() / centerpoint) * centerpoint)));     this.sety(((math.round(this.gety() / centerpoint) * centerpoint)));     this.line.updateposition(); }); 

demo: http://jsfiddle.net/lavrton/5wkph/28/


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -