kopia lustrzana https://github.com/backface/turtlestitch
fixes and enhancements for nested sprites
when dragging an anchor, also drag its parts. let users adjust parts’ positions via the context menu “move” optionpull/3/merge
rodzic
f829635106
commit
60554d0059
30
objects.js
30
objects.js
|
@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/
|
||||||
|
|
||||||
// Global stuff ////////////////////////////////////////////////////////
|
// Global stuff ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
modules.objects = '2015-June-25';
|
modules.objects = '2015-July-26';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -2658,7 +2658,7 @@ SpriteMorph.prototype.userMenu = function () {
|
||||||
}
|
}
|
||||||
menu.addItem("duplicate", 'duplicate');
|
menu.addItem("duplicate", 'duplicate');
|
||||||
menu.addItem("delete", 'remove');
|
menu.addItem("delete", 'remove');
|
||||||
menu.addItem("move", 'move');
|
menu.addItem("move", 'moveCenter');
|
||||||
if (!this.isClone) {
|
if (!this.isClone) {
|
||||||
menu.addItem("edit", 'edit');
|
menu.addItem("edit", 'edit');
|
||||||
}
|
}
|
||||||
|
@ -3176,12 +3176,20 @@ SpriteMorph.prototype.positionTalkBubble = function () {
|
||||||
SpriteMorph.prototype.prepareToBeGrabbed = function (hand) {
|
SpriteMorph.prototype.prepareToBeGrabbed = function (hand) {
|
||||||
this.removeShadow();
|
this.removeShadow();
|
||||||
this.recordLayers();
|
this.recordLayers();
|
||||||
if (!this.bounds.containsPoint(hand.position())) {
|
if (!this.bounds.containsPoint(hand.position()) &&
|
||||||
|
this.isCorrectingOutsideDrag()) {
|
||||||
this.setCenter(hand.position());
|
this.setCenter(hand.position());
|
||||||
}
|
}
|
||||||
this.addShadow();
|
this.addShadow();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SpriteMorph.prototype.isCorrectingOutsideDrag = function () {
|
||||||
|
// make sure I don't "trail behind" the hand when dragged
|
||||||
|
// override for morphs that you want to be dragged outside
|
||||||
|
// their full bounds
|
||||||
|
return !this.parts.length;
|
||||||
|
};
|
||||||
|
|
||||||
SpriteMorph.prototype.justDropped = function () {
|
SpriteMorph.prototype.justDropped = function () {
|
||||||
this.restoreLayers();
|
this.restoreLayers();
|
||||||
this.positionTalkBubble();
|
this.positionTalkBubble();
|
||||||
|
@ -3240,6 +3248,22 @@ SpriteMorph.prototype.moveBy = function (delta, justMe) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SpriteMorph.prototype.silentMoveBy = function (delta, justMe) {
|
||||||
|
SpriteMorph.uber.silentMoveBy.call(this, delta);
|
||||||
|
if (!justMe && this.parent instanceof HandMorph) {
|
||||||
|
this.parts.forEach(function (part) {
|
||||||
|
part.moveBy(delta);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SpriteMorph.prototype.rootForGrab = function () {
|
||||||
|
if (this.anchor) {
|
||||||
|
return this.anchor.rootForGrab();
|
||||||
|
}
|
||||||
|
return SpriteMorph.uber.rootForGrab.call(this);
|
||||||
|
};
|
||||||
|
|
||||||
SpriteMorph.prototype.slideBackTo = function (situation, inSteps) {
|
SpriteMorph.prototype.slideBackTo = function (situation, inSteps) {
|
||||||
// override the inherited default to make sure my parts follow
|
// override the inherited default to make sure my parts follow
|
||||||
var steps = inSteps || 5,
|
var steps = inSteps || 5,
|
||||||
|
|
Ładowanie…
Reference in New Issue