[RESOLVED] Calling script after page has completely finished loading?
Hello everyone.
I'm working on a slideshow for a portfolio-like page. In order to make sure that the portfolio-page never gets higher than the actual page, I'm binding document.resize after document.ready fires (using jQuery). However, this script is not working as it should, and I'm not sure why. The issue I'm having is that when the document loads, and the slideshow fires the first time, the images end up sort of stacked on top of each other, and not side-by-side.
This is where it all starts, sort of. It binds to the event, fires it and then starts up the slideShow.
Code:
jQuery(document).ready( function() {
var b = $(document);
$(window).resize(function () {
$('.img-wrapper').width("100%");
var height = b.height();
var headerHeight = $('.header-wrapper').height();
var footerHeight = $('.footer').height();
var innerHeight = height - (headerHeight + footerHeight);
var upperHeight = innerHeight*0.6-10;
var lowerHeight = innerHeight*0.4;
var width = Math.round(1.067615658362989*lowerHeight);
jQuery('.main').css('height', innerHeight + 'px');
jQuery('.main-content').css('height', upperHeight + 'px');
jQuery('.main-extras').css('height', lowerHeight + 'px');
$('.main-extra1').width(width);
$('.main-extra1').css('right', $('.img-wrapper').width()/2+10);
$('.main-extra2').width(width);
$('.main-extra2').css('left', $('.img-wrapper').width()/2+10);
});
jQuery(window).trigger('resize');
docReady();
});
function docReady(){
if (typeof(tid) !== undefined){
clearInterval(tid);
}
var params = Array();
var mainHeight = $('.main').height();
var mainWidth = $('.main').width();
params.push(mainHeight);
params.push(mainWidth);
var slideShowImages = new slideShowImageSet(ShowPics, params);
var tid = slideShowFunc(slideShowImages,params);
}
There's also this piece of code which does the actual slideshow-starting.
Code:
function slideShowFunc(slideShowImages,param) {
var show = new slideShow(slideShowImages, param);
updateSlideShow(show);
var tid = self.setInterval(function () {updateSlideShow(show)}, 10000);
return tid;
The first time the slideshow fires, we get this, which looks horrible. Hopefully my code is understandable, I'm quite new to JS and jQuery, but I think there is something else playing here. Sadly, I do not have a webserver where I can put up the page for view right now without exposing my own computer. page.jpg
Anyone have any ideas? My guess is that there is some desync when firing, so that the document is NOT ready when it tries to resize the images and calculate their positions, and then it all gets buggered from there.
Bookmarks