fix some outfits list bugs
I think I got the 0-width bug where the outfit never expands beyond 0px width, and there were also some issues with the fact that image subscriptions pointed to the current outfit object, even after that object had changed identity, so now we re-fetch from the cache by ID.
This commit is contained in:
parent
ec40e6ae67
commit
4dd2bc9549
2 changed files with 20 additions and 17 deletions
|
@ -550,7 +550,7 @@ View.Outfits = function (wardrobe) {
|
|||
|
||||
wardrobe.outfits.bind('addOutfit', function (outfit, i) {
|
||||
var next_child = outfits_list_el.children().not('.hiding').eq(i),
|
||||
outfit_el = $.tmpl('outfitTemplate', outfit);
|
||||
outfit_el = $.tmpl('outfitTemplate', outfit.clone());
|
||||
if(next_child.length) {
|
||||
outfit_el.insertBefore(next_child);
|
||||
} else {
|
||||
|
@ -558,8 +558,8 @@ View.Outfits = function (wardrobe) {
|
|||
}
|
||||
updateActiveOutfit();
|
||||
|
||||
var naturalWidth = outfit_el.width();
|
||||
log("Natural width is", naturalWidth);
|
||||
var naturalWidth = outfit_el.css('width');
|
||||
log("Natural width is", naturalWidth, outfit_el.width());
|
||||
outfit_el.width(0).animate({width: naturalWidth}, 'normal');
|
||||
listSubscribeToImage(outfit);
|
||||
});
|
||||
|
|
|
@ -1119,22 +1119,25 @@ function Wardrobe() {
|
|||
var DELAY = 5000;
|
||||
var controller = this;
|
||||
|
||||
function checkSubscription(outfit) {
|
||||
function checkSubscription(outfit_id) {
|
||||
Outfit.find(outfit_id, function (outfit) {
|
||||
log("Checking image for", outfit);
|
||||
outfit.reload(function () {
|
||||
if(outfitSubscriptionTotals[outfit.id] > 0) {
|
||||
if(outfitSubscriptionTotals[outfit_id] > 0) {
|
||||
if(outfit.image_enqueued) {
|
||||
log("Outfit image still enqueued; will try again soon", outfit);
|
||||
setTimeout(function () { checkSubscription(outfit) }, DELAY);
|
||||
setTimeout(function () { checkSubscription(outfit_id) }, DELAY);
|
||||
} else {
|
||||
// Unsubscribe everyone from this outfit and fire ready events
|
||||
delete outfitSubscriptionTotals[outfit.id];
|
||||
delete outfitSubscriptionTotals[outfit_id];
|
||||
controller.events.trigger('imageReady', outfit);
|
||||
}
|
||||
} else {
|
||||
log("Outfit was unsubscribed", outfit);
|
||||
delete outfitSubscriptionTotals[outfit.id];
|
||||
delete outfitSubscriptionTotals[outfit_id];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.subscribe = function (outfit) {
|
||||
|
@ -1146,7 +1149,7 @@ function Wardrobe() {
|
|||
} else {
|
||||
// This is a new subscription! Let's start checking it.
|
||||
outfitSubscriptionTotals[outfit.id] = 1;
|
||||
checkSubscription(outfit);
|
||||
checkSubscription(outfit.id);
|
||||
}
|
||||
|
||||
// Regardless, trigger the enqueued event for the new consumer's sake.
|
||||
|
|
Loading…
Reference in a new issue