kopia lustrzana https://github.com/backface/turtlestitch
fixed part of #154 - prevent costumes from being drawn while they are loading
prevents an occasional DOM error saying "an attempt was made to use an object that is not, or is no longer, usable" when loading a project that has costumespull/3/merge
rodzic
0947fbb80e
commit
c0a0c1f4a7
|
@ -1910,3 +1910,5 @@ ______
|
|||
------
|
||||
* Cloud: encodeDict() fix and new parseDict() method - used for accessing shared projects
|
||||
* GUI: fixed #119, #149 (accessing a shared projects requires lowercasing the username)
|
||||
* Portuguese translation update for SPLIT block, thanks, Manuel!
|
||||
* Store, Objects: prevent costumes from being drawn while they are loading, fixes parts of #154
|
||||
|
|
20
objects.js
20
objects.js
|
@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.objects = '2013-September-16';
|
||||
modules.objects = '2013-September-17';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -1248,6 +1248,8 @@ SpriteMorph.prototype.drawNew = function () {
|
|||
currentCenter = this.center(),
|
||||
facing, // actual costume heading based on my rotation style
|
||||
isFlipped,
|
||||
isLoadingCostume = this.costume &&
|
||||
typeof this.costume.loaded === 'function',
|
||||
pic, // (flipped copy of) actual costume based on my rotation style
|
||||
stageScale = this.parent instanceof StageMorph ?
|
||||
this.parent.scale : 1,
|
||||
|
@ -1257,7 +1259,8 @@ SpriteMorph.prototype.drawNew = function () {
|
|||
shift,
|
||||
corner,
|
||||
costumeExtent,
|
||||
ctx;
|
||||
ctx,
|
||||
handle;
|
||||
|
||||
if (this.isWarped) {
|
||||
this.wantsRedraw = true;
|
||||
|
@ -1271,7 +1274,7 @@ SpriteMorph.prototype.drawNew = function () {
|
|||
isFlipped = true;
|
||||
}
|
||||
}
|
||||
if (this.costume) {
|
||||
if (this.costume && !isLoadingCostume) {
|
||||
pic = isFlipped ? this.costume.flipped() : this.costume;
|
||||
|
||||
// determine the rotated costume's bounding box
|
||||
|
@ -1328,6 +1331,17 @@ SpriteMorph.prototype.drawNew = function () {
|
|||
this.setCenter(currentCenter, true); // just me
|
||||
SpriteMorph.uber.drawNew.call(this, facing);
|
||||
this.rotationOffset = this.extent().divideBy(2);
|
||||
if (isLoadingCostume) { // retry until costume is done loading
|
||||
handle = setInterval(
|
||||
function () {
|
||||
myself.changed();
|
||||
myself.drawNew();
|
||||
myself.changed();
|
||||
clearInterval(handle);
|
||||
},
|
||||
100
|
||||
);
|
||||
}
|
||||
}
|
||||
this.version = Date.now();
|
||||
};
|
||||
|
|
3
store.js
3
store.js
|
@ -61,7 +61,7 @@ SyntaxElementMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.store = '2013-August-10';
|
||||
modules.store = '2013-September-17';
|
||||
|
||||
|
||||
// XML_Serializer ///////////////////////////////////////////////////////
|
||||
|
@ -673,6 +673,7 @@ SnapSerializer.prototype.loadCostumes = function (object, model) {
|
|||
} else {
|
||||
costume.loaded = function () {
|
||||
object.wearCostume(costume);
|
||||
this.loaded = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue