Cancel a draggable 'dragmove' on kineticjs? -
i have set limit movement of circle when coordinate 'y' on pixel 'y-15', on specific coordinate (x,y). i've tried use 'draggable=true' event 'mouseup' , 'mousedown', can't results need. can me, please?
my code is:
circle.on('mouseover',function(){ this.setattr('draggable',true); }); circle.on('dragmove',function(e){ var mousepos = stage.getmouseposition(); var x = mousepos.x; var y = mousepos.y; if(y < y2- 15){ //do } else{ this.setattr('draggable',false); } });
if understand correctly, want dragboundfunc.
see tutorial:
// bound below y=50 var bluegroup = new kinetic.group({ x: 100, y: 70, draggable: true, dragboundfunc: function(pos) { var newy = pos.y < 50 ? 50 : pos.y; return { x: pos.x, y: newy }; } }); you'll have modify code y-15 when grab mouse coordinates, , set dragboundfunc reflect coordinates clicked on.
if you're trying limit y-axis on known fixed y value, becomes easier, how tutorial shows you, except have change coordinate want limit y to.
check 1 quick reference too:
Comments
Post a Comment