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:

http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-bounds-tutorial-with-kineticjs/

    // 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:

http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-shapes-horizontally-or-vertically-tutorial/


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -