From e597c4717121d4f2df169070654cb424591a080b Mon Sep 17 00:00:00 2001 From: Pete Richards Date: Wed, 30 Sep 2015 15:25:12 -0700 Subject: [PATCH] only update viewport during animation frames --- .../src/controllers/PlotController.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/platform/features/plot-reborn/src/controllers/PlotController.js b/platform/features/plot-reborn/src/controllers/PlotController.js index a7e7918075..a6c1a61d26 100644 --- a/platform/features/plot-reborn/src/controllers/PlotController.js +++ b/platform/features/plot-reborn/src/controllers/PlotController.js @@ -1,4 +1,4 @@ -/*global define*/ +/*global define,requestAnimationFrame*/ define( [], @@ -14,7 +14,8 @@ define( isLive = true, extrema = {}, unsubscribes = [], - palette = new colorService.ColorPalette(); + palette = new colorService.ColorPalette(), + pendingUpdate; function setToDefaultViewport() { @@ -198,9 +199,16 @@ define( } function followDataIfLive() { - if (isLive) { - $scope.viewport = viewportForExtrema(); + if (pendingUpdate) { + return; } + requestAnimationFrame(function () { + if (isLive) { + $scope.viewport = viewportForExtrema(); + } + pendingUpdate = false; + }); + pendingUpdate = true; } $scope.$on('series:data:add', followDataIfLive);