diff --git a/src/app/theme/directives/zoomIn.js b/src/app/theme/directives/zoomIn.js index f22c7c57a..59b78e321 100644 --- a/src/app/theme/directives/zoomIn.js +++ b/src/app/theme/directives/zoomIn.js @@ -14,7 +14,7 @@ link: function ($scope, elem) { var delay = 1000; - if ($rootScope.$pageLoaded) { + if ($rootScope.$pageFinishedLoading) { delay = 100; } diff --git a/src/app/theme/services/preloader.js b/src/app/theme/services/preloader.js index 9f94b458c..b21ba27e2 100644 --- a/src/app/theme/services/preloader.js +++ b/src/app/theme/services/preloader.js @@ -11,11 +11,23 @@ /** @ngInject */ function preloader($q) { return { - load: function (src) { + loadImg: function (src) { var d = $q.defer(); var img = new Image(); img.src = src; - img.onload = d.resolve; + img.onload = function(){ + console.log("img " + src + " loaded"); + d.resolve(); + }; + return d.promise; + }, + loadAmCharts : function(){ + var d = $q.defer(); + console.log("amchart"); + AmCharts.ready(function(){ + console.log("amchart loaded"); + d.resolve(); + }); return d.promise; } } diff --git a/src/app/theme/theme.run.js b/src/app/theme/theme.run.js index 656b3ce0a..b9e2ef63e 100644 --- a/src/app/theme/theme.run.js +++ b/src/app/theme/theme.run.js @@ -12,28 +12,19 @@ function themeRun($timeout, $rootScope, layoutSizes, layoutPaths, preloader, $q) { $q.all([ - preloader.load(layoutPaths.images.root + 'blur-bg.jpg'), - preloader.load(layoutPaths.images.root + 'blur-bg-blurred.jpg') + preloader.loadImg(layoutPaths.images.root + 'blur-bg.jpg'), + preloader.loadImg(layoutPaths.images.root + 'blur-bg-blurred.jpg'), + preloader.loadAmCharts(), + $timeout(3000) ]).then(function(){ - if(!$rootScope.$pageFinishedLoading){ $rootScope.$pageFinishedLoading = true; - } - if(!$rootScope.$pageLoaded){ - $rootScope.$pageLoaded = true; - } }); $timeout(function () { if(!$rootScope.$pageFinishedLoading){ $rootScope.$pageFinishedLoading = true; } - }, 2000); - - $timeout(function () { - if(!$rootScope.$pageLoaded){ - $rootScope.$pageLoaded = true; - } - }, 4000); + }, 7000); $rootScope.$isMenuCollapsed = window.innerWidth <= layoutSizes.resWidthCollapseSidebar; }