OK, hopefully I can explain what's happening so you get it. When we do:
Code:
//triggered when all images are loaded
var loadComplete = function() {
$(jOverlay).fadeOut(800, function() {
$(jOverlay).remove();
onComplete(); //callback function
});
}
That means that when the loadComplete function is called this happens:
The element(s) (if any) represented by $(jOverlay) fade out over a period of 800 milliseconds. Once that's done, this anonymous function runs:
Code:
function() {
$(jOverlay).remove();
onComplete(); //callback function
}
The first line of which removes the element(s) (if any) represented by $(jOverlay) and their children (again, if any), while at the time eliminating any events associated with them (again, if any).
The next line simply runs another function by the name of 'onComplete'. If such a function exist within the scope accessible to this code, it will run, otherwise, nothing will happen.
That's all well and good, but then when you do/add to it like so:
Code:
onComplete('html, body').animate({scrollTop : 0},200); //callback function
That's basically jQuery/javascript jibberish and essentially means nothing, and probably throws an error. But it may not. In either case it doesn't do anything.
Now there could be other issues - like the syntax itself might be off (but it looks good, I just tested it in Chrome), if that's OK like it looks to be, what you can do is this (simplest solution, there are others):
Code:
//triggered when all images are loaded
var loadComplete = function() {
$(jOverlay).fadeOut(800, function() {
$(jOverlay).remove();
$('html, body').animate({scrollTop : 0},200);
});
}
Feel free to ask any questions, but if there are still problems after editing the code as I suggest, and refreshing the page and/or clearing the cache, it would help me a lot to help you if you could provide a link to the problematic page, so I can check it out.
Bookmarks