From ae5ad01db9c7cd2959c387973ef39c06d4af7f6a Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Tue, 3 Mar 2015 23:48:45 +0100 Subject: [PATCH] Animations ! --- js/crep.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/js/crep.js b/js/crep.js index 7093f6d..2679c65 100755 --- a/js/crep.js +++ b/js/crep.js @@ -37,16 +37,35 @@ function dynamiseLinks(el) { function loadDoc(location, callback) { if (!callback) { - callaback = function () { + callback = function () { return undefined } } + var eventsLeft = 2 + var html = '' + + function events() { + eventsLeft += -1 + if (eventsLeft <= 0) { + mainContainer.html(html) + dynamiseLinks(mainContainer) + pageSpecific(location) + mainContainer.animate({ + height: "toggle", + opacity: 1 + }) + console.debug(callback) + callback() + } + } + var mainContainer = $("#mainContainer") + mainContainer.animate({ + height: "toggle", + opacity: 0 + }, 'fast', events) $.get(location + '?c', function (data) { - mainContainer = $("#mainContainer") - mainContainer.html(data) - dynamiseLinks(mainContainer) - pageSpecific(location) - callback() + html = data + events() }) } -- libgit2 0.21.2