schacon/showoff — Issue #145: margin-top is not calculated correctly every time
Author: shamansir
Created: 2011-10-23 20:18:05+00:00
State: open

In my case, for the same slides, I get the different margin-top on sudden browser refreshes, I suppose the reason is in the fact that not all of the content is loaded for the time of calculation in different cases. For this code:

function centerSlide(slide) {
var slide_content = $(slide).children(".content").first();
var height = slide_content.height();
var mar_top = (0.5 * parseFloat($(slide).height())) - (0.5 * parseFloat(height));
console.log(mar_top, $(slide).height(), height, (0.5 * parseFloat($(slide).height())) - (0.5 * parseFloat(height)));
if (mar_top < 0) {
mar_top = 0
};
slide_content.css('margin-top', mar_top)
}

I get:

236 768 296 236 // in 30% cases
61.5 768 645 61.5 // in 70% cases