From 1e754b8ca2534205cb3573aa110081d448aa8d16 Mon Sep 17 00:00:00 2001 From: Maik de Kruif Date: Fri, 24 Sep 2021 09:49:00 +0200 Subject: [PATCH] Fix error when no masonry is found --- themes/maik-blog/assets/js/list_columns.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themes/maik-blog/assets/js/list_columns.js b/themes/maik-blog/assets/js/list_columns.js index 563a39e..19958c3 100644 --- a/themes/maik-blog/assets/js/list_columns.js +++ b/themes/maik-blog/assets/js/list_columns.js @@ -7,9 +7,12 @@ function resizeItem(masonry, item){ function resizeAll(){ let masonry = document.getElementsByClassName("masonry")[0]; + + if (!masonry) return; + masonry.style.gridAutoRows = "20px" masonry.style.marginBottom = "80px" - let allItems = document.getElementsByClassName("masonry-item"); + let allItems = masonry.getElementsByClassName("masonry-item"); for (const item of allItems) { resizeItem(masonry, item)