kopia lustrzana https://github.com/backface/turtlestitch
tweak "undrop / redrop" animation
rodzic
4f3d282d95
commit
dae8e7a7bb
29
blocks.js
29
blocks.js
|
@ -5824,7 +5824,11 @@ ScriptsMorph.prototype.undrop = function () {
|
|||
this.dropRecord.situation =
|
||||
this.dropRecord.lastDroppedBlock.situation();
|
||||
}
|
||||
this.recoverLastDrop().slideBackTo(this.dropRecord.lastOrigin);
|
||||
this.dropRecord.lastDroppedBlock.slideBackTo(
|
||||
this.dropRecord.lastOrigin,
|
||||
null,
|
||||
this.recoverLastDrop()
|
||||
);
|
||||
this.dropRecord = this.dropRecord.lastRecord;
|
||||
};
|
||||
|
||||
|
@ -5832,15 +5836,24 @@ ScriptsMorph.prototype.redrop = function () {
|
|||
if (!this.dropRecord || !this.dropRecord.nextRecord) {return; }
|
||||
this.dropRecord = this.dropRecord.nextRecord;
|
||||
if (this.dropRecord.action === 'delete') {
|
||||
this.recoverLastDrop(true).destroy();
|
||||
this.recoverLastDrop(true);
|
||||
this.dropRecord.lastDroppedBlock.destroy();
|
||||
} else {
|
||||
this.recoverLastDrop(true).slideBackTo(this.dropRecord.situation);
|
||||
this.dropRecord.lastDroppedBlock.slideBackTo(
|
||||
this.dropRecord.situation,
|
||||
null,
|
||||
this.recoverLastDrop(true)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
ScriptsMorph.prototype.recoverLastDrop = function (forRedrop) {
|
||||
// retrieve the block last touched by the user and answer a function
|
||||
// to be called after the animation that moves it back right before
|
||||
// dropping it into its former situation
|
||||
var rec = this.dropRecord,
|
||||
dropped,
|
||||
onBeforeDrop,
|
||||
parent;
|
||||
|
||||
if (!rec || !rec.lastDroppedBlock) {
|
||||
|
@ -5882,7 +5895,9 @@ ScriptsMorph.prototype.recoverLastDrop = function (forRedrop) {
|
|||
);
|
||||
if (rec.lastWrapParent instanceof CommandBlockMorph) {
|
||||
if (forRedrop) {
|
||||
cslot.nestedBlock(rec.lastDropTarget.element);
|
||||
onBeforeDrop = function () {
|
||||
cslot.nestedBlock(rec.lastDropTarget.element);
|
||||
};
|
||||
} else {
|
||||
rec.lastWrapParent.nextBlock(
|
||||
rec.lastDropTarget.element
|
||||
|
@ -5890,7 +5905,9 @@ ScriptsMorph.prototype.recoverLastDrop = function (forRedrop) {
|
|||
}
|
||||
} else if (rec.lastWrapParent instanceof CommandSlotMorph) {
|
||||
if (forRedrop) {
|
||||
cslot.nestedBlock(rec.lastDropTarget.element);
|
||||
onBeforeDrop = function () {
|
||||
cslot.nestedBlock(rec.lastDropTarget.element);
|
||||
};
|
||||
} else {
|
||||
rec.lastWrapParent.nestedBlock(
|
||||
rec.lastDropTarget.element
|
||||
|
@ -5945,7 +5962,7 @@ ScriptsMorph.prototype.recoverLastDrop = function (forRedrop) {
|
|||
}
|
||||
}
|
||||
|
||||
return dropped;
|
||||
return onBeforeDrop;
|
||||
};
|
||||
|
||||
ScriptsMorph.prototype.clearDropInfo = function () {
|
||||
|
|
7
gui.js
7
gui.js
|
@ -1060,6 +1060,13 @@ IDE_Morph.prototype.createPalette = function (forSearching) {
|
|||
}
|
||||
};
|
||||
|
||||
this.palette.contents.reactToDropOf = function (droppedMorph) {
|
||||
// for "undrop" operation
|
||||
if (droppedMorph instanceof BlockMorph) {
|
||||
droppedMorph.destroy();
|
||||
}
|
||||
};
|
||||
|
||||
this.palette.setWidth(this.logo.width());
|
||||
this.add(this.palette);
|
||||
return this.palette;
|
||||
|
|
|
@ -3125,3 +3125,5 @@ http://snap.berkeley.edu/run#cloud:Username=jens&ProjectName=rotation
|
|||
161122
|
||||
------
|
||||
* Blocks, GUI: “Undrop / Redrop” for deleting blocks via the context menu or in keyboard edit mode
|
||||
* Morphic: support optional “onBeforeDrop” callback parameter in Morph.slideBackTo()
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue