mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-10 15:02:06 -05:00
Merge pull request #16 from tmickel/bugfix/fix-move
Shuffle moveBlock to allow case where e.oldParent !== undefined
This commit is contained in:
commit
7eef10ef8c
3 changed files with 38 additions and 34 deletions
|
@ -130,8 +130,23 @@ Runtime.prototype.changeBlock = function (args) {
|
||||||
Runtime.prototype.moveBlock = function (e) {
|
Runtime.prototype.moveBlock = function (e) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
// Block has a new parent
|
// Block was removed from parent
|
||||||
if (e.oldParent === undefined && e.newParent !== undefined) {
|
if (e.newParent === undefined && e.oldParent !== undefined) {
|
||||||
|
// Add stack
|
||||||
|
_this.stacks.push(e.id);
|
||||||
|
|
||||||
|
// Update old parent
|
||||||
|
if (e.oldField === undefined) {
|
||||||
|
_this.blocks[e.oldParent].next = null;
|
||||||
|
} else {
|
||||||
|
delete _this.blocks[e.oldParent].fields[e.oldField];
|
||||||
|
}
|
||||||
|
} else if (e.newParent !== undefined) {
|
||||||
|
// Block was moved to a new parent
|
||||||
|
// Either happens because it was previously parentless
|
||||||
|
// (e.oldParent === undefined)
|
||||||
|
// or because a block was moved in front of it.
|
||||||
|
|
||||||
// Remove stack
|
// Remove stack
|
||||||
_this._deleteStack(e.id);
|
_this._deleteStack(e.id);
|
||||||
|
|
||||||
|
@ -146,19 +161,6 @@ Runtime.prototype.moveBlock = function (e) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block was removed from parent
|
|
||||||
if (e.newParent === undefined && e.oldParent !== undefined) {
|
|
||||||
// Add stack
|
|
||||||
_this.stacks.push(e.id);
|
|
||||||
|
|
||||||
// Update old parent
|
|
||||||
if (e.oldField === undefined) {
|
|
||||||
_this.blocks[e.oldParent].next = null;
|
|
||||||
} else {
|
|
||||||
delete _this.blocks[e.oldParent].fields[e.oldField];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
32
vm.js
32
vm.js
|
@ -1308,8 +1308,23 @@
|
||||||
Runtime.prototype.moveBlock = function (e) {
|
Runtime.prototype.moveBlock = function (e) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
// Block has a new parent
|
// Block was removed from parent
|
||||||
if (e.oldParent === undefined && e.newParent !== undefined) {
|
if (e.newParent === undefined && e.oldParent !== undefined) {
|
||||||
|
// Add stack
|
||||||
|
_this.stacks.push(e.id);
|
||||||
|
|
||||||
|
// Update old parent
|
||||||
|
if (e.oldField === undefined) {
|
||||||
|
_this.blocks[e.oldParent].next = null;
|
||||||
|
} else {
|
||||||
|
delete _this.blocks[e.oldParent].fields[e.oldField];
|
||||||
|
}
|
||||||
|
} else if (e.newParent !== undefined) {
|
||||||
|
// Block was moved to a new parent
|
||||||
|
// Either happens because it was previously parentless
|
||||||
|
// (e.oldParent === undefined)
|
||||||
|
// or because a block was moved in front of it.
|
||||||
|
|
||||||
// Remove stack
|
// Remove stack
|
||||||
_this._deleteStack(e.id);
|
_this._deleteStack(e.id);
|
||||||
|
|
||||||
|
@ -1324,19 +1339,6 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block was removed from parent
|
|
||||||
if (e.newParent === undefined && e.oldParent !== undefined) {
|
|
||||||
// Add stack
|
|
||||||
_this.stacks.push(e.id);
|
|
||||||
|
|
||||||
// Update old parent
|
|
||||||
if (e.oldField === undefined) {
|
|
||||||
_this.blocks[e.oldParent].next = null;
|
|
||||||
} else {
|
|
||||||
delete _this.blocks[e.oldParent].fields[e.oldField];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
8
vm.min.js
vendored
8
vm.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue