Merge pull request #1390 from brollb/1207-go-back-layers

'go to back' on large num in 'go back' block. Fixes #1207
pull/29/head
Jens Mönig 2017-01-09 17:56:11 +01:00 zatwierdzone przez GitHub
commit ce5561faa8
1 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -3201,12 +3201,15 @@ SpriteMorph.prototype.comeToFront = function () {
};
SpriteMorph.prototype.goBack = function (layers) {
var layer, newLayer = +layers || 0;
var layer,
newLayer = +layers,
targetLayer;
if (!this.parent) {return null; }
layer = this.parent.children.indexOf(this);
if (layer < newLayer) {return null; }
this.parent.removeChild(this);
this.parent.children.splice(layer - newLayer, null, this);
targetLayer = Math.max(layer - newLayer, 0);
this.parent.children.splice(targetLayer, null, this);
this.parent.changed();
};