Search code examples
javascriptimagekineticjsdrag

Drag a Kinetic.Image when edit other Kinetic.Image


I have 2 Kinetic.Image (A and B) in my canvas. I want that when I try move A, only the Kinetic.Image B change, and the A doesn't change it position.

My code is:

A.on('dragmove',function(event) {
    var x = B.getX();
    var y = B.getY();
    .
    .
    .
});

Thank you!


Solution

  • What about this:

    image1.on('dragstart', function() {
      this.stopDrag();
      image2.startDrag();
    });
    

    http://jsbin.com/qamexu/1/edit

    I think you can try to use dragBoundFunc property here.