Fixed push-bug

This commit is contained in:
Oliver Rümpelein 2014-10-24 17:15:24 +02:00
parent 10428e7fa1
commit 9de08a7e20

View file

@ -64,7 +64,8 @@
.onHit("coll", function(hb) { .onHit("coll", function(hb) {
/* If object hits something it shouldn't, release it from influence of mouse /* If object hits something it shouldn't, release it from influence of mouse
*/ */
this.stopDrag(); var t=cur_sel.graphelement;
t.stopDrag();
if (hb[0].normal && (! isNaN(hb[0].overlap)) ) { if (hb[0].normal && (! isNaN(hb[0].overlap)) ) {
/* If it ends up overlapping with oneo r several other objects, /* If it ends up overlapping with oneo r several other objects,
* push it back as long as necessary * push it back as long as necessary
@ -72,11 +73,11 @@
do { do {
var nor=hb[0].normal; var nor=hb[0].normal;
var ol=hb[0].overlap; var ol=hb[0].overlap;
this.x += Math.ceil(nor.x * -ol); t.x += Math.ceil(nor.x * -ol);
this.y += Math.ceil(nor.y * -ol); t.y += Math.ceil(nor.y * -ol);
} }
while( (hb=this.hit("coll")) && (this.hit("coll")[0].normal) && while( (hb=t.hit("coll")) && (t.hit("coll")[0].normal) &&
(this.hit("coll")[0].overlap) ); (t.hit("coll")[0].overlap) );
} }
}); });