0

I'm familiar with kineticJS and have just come across my first problem which i'm hoping someone will be able to help with.

What i'd like to do is drag one shape (a trigger shape) over another shape (a target shape) and in doing so fire off an event or function (in this case an AJAX post).

The other thing is i'd like to do is pass information (names) of both shapes into the ajax post.

(doing the ajax post itself is not an issue, it's the triggering event and getting info of both shapes)

Thanks in advance

4

1 回答 1

0
trigger.on('dragend', function() {

        var x = trigger.getX();
        var y = trigger.getY();
        var triggerName = trigger.getName();


 var children = triggerLayer.getChildren();
 for( var i=0; i<children.length; i++){


  if(x > (children[i].getX()- children[i].getWidth()/2)  &&
     x < (children[i].getX()+ children[i].getWidth()/2)  &&
     y > (children[i].getY()- children[i].getHeight()/2) &&
     y < (children[i].getY()+ children[i].getHeight()/2)
    )
 {

 alert(triggerName + "has activated" + children[i].getName())
 ///ajax post
 } 




 }   
于 2013-04-19T18:04:18.673 回答