From ecf97f56c31273cecdd429c694b36d94dd15473e Mon Sep 17 00:00:00 2001 From: Levko Kravets Date: Mon, 13 May 2019 19:45:34 +0300 Subject: [PATCH] getredash/redash#3753 resize-event: take into account transformations and transitions --- client/app/directives/resize-event.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/client/app/directives/resize-event.js b/client/app/directives/resize-event.js index d91f59d64c..a0c4d5bed0 100644 --- a/client/app/directives/resize-event.js +++ b/client/app/directives/resize-event.js @@ -4,20 +4,22 @@ const items = new Map(); function checkItems() { items.forEach((item, node) => { - const offsetWidth = node.offsetWidth; - const offsetHeight = node.offsetHeight; + const bounds = node.getBoundingClientRect(); + // convert to int (because these numbers needed for comparisons), but preserve 1 decimal point + const width = Math.round(bounds.width * 10); + const height = Math.round(bounds.height * 10); if ( - (item.offsetWidth !== offsetWidth) || - (item.offsetHeight !== offsetHeight) + (item.width !== width) || + (item.height !== height) ) { - item.offsetWidth = offsetWidth; - item.offsetHeight = offsetHeight; + item.width = width; + item.height = height; item.callback(node); } }); - setTimeout(checkItems, 50); + setTimeout(checkItems, 100); } checkItems(); // ensure it was called only once!