Cards: Limit movement to positive coordinates.

This commit is contained in:
2015-10-01 22:16:51 +02:00
parent 730602a0f3
commit d706c85814

View File

@@ -76,7 +76,9 @@ Toolbox.prototype = {
} }
return relPos; return relPos;
}, },
SetPosition: function(x, y){ SetPosition: function (x, y) {
if (x < 0) { x = 0; }
if (y < 0) { y = 0; }
this.X = x; this.X = x;
this.Y = y; this.Y = y;
this.divToolbox.style.left = x + "px"; this.divToolbox.style.left = x + "px";
@@ -264,6 +266,8 @@ Card.prototype = {
this.animData = null; this.animData = null;
}, },
Move: function (x, y) { Move: function (x, y) {
if (x < 0) { x = 0; }
if (y < 0) { y = 0; }
this.OnMoveStart(); this.OnMoveStart();
this.X = x; this.X = x;
this.Y = y; this.Y = y;
@@ -481,6 +485,8 @@ Card.prototype = {
var pos = this.GetRelativePosToContainer({ x: evt.clientX, y: evt.clientY }); var pos = this.GetRelativePosToContainer({ x: evt.clientX, y: evt.clientY });
this.newX = parseInt(pos.x - this.offsetX); this.newX = parseInt(pos.x - this.offsetX);
this.newY = parseInt(pos.y - this.offsetY); this.newY = parseInt(pos.y - this.offsetY);
if (this.newX < 0) { this.newX = 0; }
if (this.newY < 0) { this.newY = 0; }
this.divCard.style.left = this.newX + "px"; this.divCard.style.left = this.newX + "px";
this.divCard.style.top = this.newY + "px"; this.divCard.style.top = this.newY + "px";
@@ -517,6 +523,8 @@ Card.prototype = {
var pos = this.GetRelativePosToContainer({ x: evt.touches[0].clientX, y: evt.touches[0].clientY }); var pos = this.GetRelativePosToContainer({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });
this.newX = parseInt(pos.x - this.offsetX); this.newX = parseInt(pos.x - this.offsetX);
this.newY = parseInt(pos.y - this.offsetY); this.newY = parseInt(pos.y - this.offsetY);
if (this.newX < 0) { this.newX = 0; }
if (this.newY < 0) { this.newY = 0; }
this.divCard.style.left = this.newX + "px"; this.divCard.style.left = this.newX + "px";
this.divCard.style.top = this.newY + "px"; this.divCard.style.top = this.newY + "px";