From 019b3fd8f6c34551511a1c62af18a32a1618dbbe Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Mon, 24 Sep 2018 12:08:22 +0200 Subject: [PATCH] [ML] Fixes Anomaly Explorer resize listener. --- x-pack/plugins/ml/public/explorer/explorer_controller.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/explorer/explorer_controller.js b/x-pack/plugins/ml/public/explorer/explorer_controller.js index f7b93edf7b40a..6b7e7d29adfd6 100644 --- a/x-pack/plugins/ml/public/explorer/explorer_controller.js +++ b/x-pack/plugins/ml/public/explorer/explorer_controller.js @@ -284,13 +284,15 @@ module.controller('MlExplorerController', function ( }); // Redraw the swimlane when the window resizes or the global nav is toggled. - $(window).resize(() => { + function jqueryRedrawOnResize() { + if (resizeTimeout !== null) { $timeout.cancel(resizeTimeout); } // Only redraw 500ms after last resize event. resizeTimeout = $timeout(redrawOnResize, 500); - }); + } + $(window).resize(jqueryRedrawOnResize); const navListener = $scope.$on('globalNav:update', () => { // Run in timeout so that content pane has resized after global nav has updated. @@ -508,6 +510,7 @@ module.controller('MlExplorerController', function ( mlSelectLimitService.state.unwatch(swimlaneLimitListener); delete $scope.cellData; refreshWatcher.cancel(); + $(window).off('resize', jqueryRedrawOnResize); // Cancel listening for updates to the global nav state. navListener(); });