From 89f9efd3a3de9316d5163ccc68d74d8802b90406 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 3 Jun 2016 11:53:37 -0700 Subject: [PATCH] Fixing the dashboard's look after resizing the window (#556) --- caravel/assets/javascripts/dashboard.jsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/caravel/assets/javascripts/dashboard.jsx b/caravel/assets/javascripts/dashboard.jsx index b28d31c591c7c..3d050d8877a1d 100644 --- a/caravel/assets/javascripts/dashboard.jsx +++ b/caravel/assets/javascripts/dashboard.jsx @@ -214,6 +214,7 @@ var Dashboard = function (dashboardData) { this.slices = sliceObjects; this.refreshTimer = null; this.startPeriodicRender(0); + this.bindResizeToWindowResize(); }, setFilter: function (slice_id, col, vals) { this.addFilter(slice_id, col, vals, false); @@ -236,6 +237,18 @@ var Dashboard = function (dashboardData) { // Returns a list of human readable active filters return JSON.stringify(this.filters, null, 4); }, + bindResizeToWindowResize: function () { + var resizeTimer; + var dash = this; + $(window).on('resize', function (e) { + clearTimeout(resizeTimer); + resizeTimer = setTimeout(function () { + dash.slices.forEach(function (slice) { + slice.resize(); + }); + }, 500); + }); + }, stopPeriodicRender: function () { if (this.refreshTimer) { clearTimeout(this.refreshTimer);