1
0
Fork 0
forked from OpenNeo/impress

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:
Emi Matchu 2012-07-31 11:14:32 -04:00
parent ec40e6ae67
commit 4dd2bc9549
2 changed files with 20 additions and 17 deletions

View file

@ -550,7 +550,7 @@ View.Outfits = function (wardrobe) {
wardrobe.outfits.bind('addOutfit', function (outfit, i) { wardrobe.outfits.bind('addOutfit', function (outfit, i) {
var next_child = outfits_list_el.children().not('.hiding').eq(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) { if(next_child.length) {
outfit_el.insertBefore(next_child); outfit_el.insertBefore(next_child);
} else { } else {
@ -558,8 +558,8 @@ View.Outfits = function (wardrobe) {
} }
updateActiveOutfit(); updateActiveOutfit();
var naturalWidth = outfit_el.width(); var naturalWidth = outfit_el.css('width');
log("Natural width is", naturalWidth); log("Natural width is", naturalWidth, outfit_el.width());
outfit_el.width(0).animate({width: naturalWidth}, 'normal'); outfit_el.width(0).animate({width: naturalWidth}, 'normal');
listSubscribeToImage(outfit); listSubscribeToImage(outfit);
}); });

View file

@ -1119,22 +1119,25 @@ function Wardrobe() {
var DELAY = 5000; var DELAY = 5000;
var controller = this; var controller = this;
function checkSubscription(outfit) { function checkSubscription(outfit_id) {
Outfit.find(outfit_id, function (outfit) {
log("Checking image for", outfit);
outfit.reload(function () { outfit.reload(function () {
if(outfitSubscriptionTotals[outfit.id] > 0) { if(outfitSubscriptionTotals[outfit_id] > 0) {
if(outfit.image_enqueued) { if(outfit.image_enqueued) {
log("Outfit image still enqueued; will try again soon", outfit); log("Outfit image still enqueued; will try again soon", outfit);
setTimeout(function () { checkSubscription(outfit) }, DELAY); setTimeout(function () { checkSubscription(outfit_id) }, DELAY);
} else { } else {
// Unsubscribe everyone from this outfit and fire ready events // Unsubscribe everyone from this outfit and fire ready events
delete outfitSubscriptionTotals[outfit.id]; delete outfitSubscriptionTotals[outfit_id];
controller.events.trigger('imageReady', outfit); controller.events.trigger('imageReady', outfit);
} }
} else { } else {
log("Outfit was unsubscribed", outfit); log("Outfit was unsubscribed", outfit);
delete outfitSubscriptionTotals[outfit.id]; delete outfitSubscriptionTotals[outfit_id];
} }
}); });
});
} }
this.subscribe = function (outfit) { this.subscribe = function (outfit) {
@ -1146,7 +1149,7 @@ function Wardrobe() {
} else { } else {
// This is a new subscription! Let's start checking it. // This is a new subscription! Let's start checking it.
outfitSubscriptionTotals[outfit.id] = 1; outfitSubscriptionTotals[outfit.id] = 1;
checkSubscription(outfit); checkSubscription(outfit.id);
} }
// Regardless, trigger the enqueued event for the new consumer's sake. // Regardless, trigger the enqueued event for the new consumer's sake.