From ffbdea78ee0cc287549458c046f1858b65f221bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 23 Aug 2014 20:23:33 +0200 Subject: [PATCH] Fix for plot dimension error when resizing window --- src/app/controllers/dashboardCtrl.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/controllers/dashboardCtrl.js b/src/app/controllers/dashboardCtrl.js index 052ad540a8c..34af5718072 100644 --- a/src/app/controllers/dashboardCtrl.js +++ b/src/app/controllers/dashboardCtrl.js @@ -17,18 +17,20 @@ function (angular, $, config, _) { $scope.editor = { index: 0 }; $scope.panelNames = config.panels; + var resizeEventTimeout; $scope.init = function() { $scope.availablePanels = config.panels; $scope.onAppEvent('setup-dashboard', $scope.setupDashboard); - - angular.element(window).bind('resize', function() { - $timeout(function() { - $scope.$broadcast('render'); - }); - }); - $scope.reset_row(); + $scope.registerWindowResizeEvent(); + }; + + $scope.registerWindowResizeEvent = function() { + angular.element(window).bind('resize', function() { + $timeout.cancel(resizeEventTimeout); + resizeEventTimeout = $timeout(function() { $scope.$broadcast('render'); }, 200); + }); }; $scope.setupDashboard = function(event, dashboardData) {