From 24c8bf4729d22aeefbdf9340d34d66aec76308e6 Mon Sep 17 00:00:00 2001 From: ifjorissen Date: Thu, 24 Jul 2014 14:28:56 -0700 Subject: [PATCH] pretty sure this will fix the header bug. added a scope varaible to check if the first include (the header) is loaded, the viz directive will execute only if it returns true --- app/scripts/controllers/main.coffee | 3 +++ app/scripts/directives/viz.coffee | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/scripts/controllers/main.coffee b/app/scripts/controllers/main.coffee index 70c5a03..1554f48 100644 --- a/app/scripts/controllers/main.coffee +++ b/app/scripts/controllers/main.coffee @@ -10,6 +10,9 @@ angular.module('soccercomparisonApp') .controller 'MainCtrl', ['$scope' ($scope) -> + $scope.$on('$includeContentLoaded', () -> + $scope.contentLoaded = true + ) $scope.showModal = -> $('#info-modal').modal('show') ] \ No newline at end of file diff --git a/app/scripts/directives/viz.coffee b/app/scripts/directives/viz.coffee index b37c677..37d57ba 100644 --- a/app/scripts/directives/viz.coffee +++ b/app/scripts/directives/viz.coffee @@ -10,6 +10,7 @@ angular.module('soccercomparisonApp') .directive('viz', -> restrict: 'E' link: (scope, element, attrs) -> + # $$window = $ $window bounceDelay = 1200 goalColors = { "Male": ["#FFF", "#008"], "Female": ["#FFF", "#700"] } @@ -252,10 +253,12 @@ angular.module('soccercomparisonApp') return ) - scope.$on('$viewContentLoaded', () -> - chart.call(colorLegend) - chart.call(playerLegend) - colorLegend.show("data", chart.node()) - playerLegend.show("data", chart.node()) + scope.$watch('scope.contentLoaded', ()-> + scope.$on('$viewContentLoaded', () -> + chart.call(colorLegend) + chart.call(playerLegend) + colorLegend.show("data", chart.node()) + playerLegend.show("data", chart.node()) ) + ) )