From 46e081fa338e3c08aa12a07aad2ac7262370e4ed Mon Sep 17 00:00:00 2001 From: Shaun M Baer Date: Tue, 2 Jul 2024 14:58:37 -0400 Subject: [PATCH] ignore items without height (ie items with "display: none") when calculating container height --- src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 3ccc9ed..684b195 100644 --- a/src/index.js +++ b/src/index.js @@ -61,7 +61,7 @@ class MagicGrid extends EventEmitter{ let style = items[i].style; style.position = "absolute"; - + if (this.animate) { style.transition = `${this.useTransform ? "transform" : "top, left"} 0.2s ease`; } @@ -171,7 +171,9 @@ class MagicGrid extends EventEmitter{ item.style.left = left; } - col.height += item.getBoundingClientRect().height + topGutter; + if ( item.getBoundingClientRect().height > 0 ) { + col.height += item.getBoundingClientRect().height + topGutter; + } if(col.height > maxHeight){ maxHeight = col.height;