|
17 | 17 | border-radius: 8px !important; |
18 | 18 | padding: 1rem !important; |
19 | 19 | box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important; |
20 | | - margin: 0 !important; |
| 20 | + margin: 0 0 15px 0 !important; /* Use margin instead of grid for vertical spacing */ |
21 | 21 | display: block !important; |
22 | 22 | width: 100% !important; |
23 | 23 | box-sizing: border-box !important; |
|
30 | 30 | border-color: #d1d5da !important; |
31 | 31 | } |
32 | 32 |
|
33 | | - /* Grid container with separate horizontal and vertical gaps */ |
| 33 | + /* Simplified grid - let CSS handle everything */ |
34 | 34 | body .media-page .media-grid, |
35 | 35 | .media-grid { |
36 | 36 | display: grid !important; |
37 | 37 | grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important; |
38 | | - grid-auto-rows: 20px !important; /* Row height for masonry calculation */ |
39 | | - row-gap: 1px !important; /* Vertical gap between rows */ |
40 | | - column-gap: 20px !important; /* Horizontal gap between columns */ |
| 38 | + column-gap: 20px !important; /* Only horizontal gap */ |
41 | 39 | align-items: start !important; |
42 | 40 | width: 100% !important; |
43 | 41 | max-width: none !important; |
@@ -119,92 +117,22 @@ <h3 class="archive__item-title"> |
119 | 117 | {% endfor %} |
120 | 118 | </section> |
121 | 119 |
|
| 120 | +<!-- Minimal JavaScript - only handle Instagram embeds --> |
122 | 121 | <script> |
123 | | -var lastHeights = []; |
124 | | -var masonryAttempts = 0; |
125 | | -var isStable = false; |
126 | | - |
127 | | -function applyMasonry() { |
128 | | - var grid = document.querySelector('.media-grid'); |
129 | | - var items = grid.querySelectorAll('.media-card'); |
130 | | - |
131 | | - var rowHeight = 20; // Match CSS grid-auto-rows |
132 | | - var verticalGap = 1; // Match CSS row-gap |
133 | | - |
134 | | - masonryAttempts++; |
135 | | - |
136 | | - // Check current heights first |
137 | | - var currentHeights = []; |
138 | | - for (var i = 0; i < items.length; i++) { |
139 | | - var rect = items[i].getBoundingClientRect(); |
140 | | - currentHeights.push(rect.height); |
141 | | - } |
142 | | - |
143 | | - // Only proceed if heights have changed or this is the first run |
144 | | - var heightsChanged = JSON.stringify(currentHeights) !== JSON.stringify(lastHeights); |
145 | | - |
146 | | - if (!heightsChanged && masonryAttempts > 1) { |
147 | | - if (!isStable) { |
148 | | - isStable = true; // Mark as stable, stop periodic checks |
149 | | - } |
150 | | - return; // No need to recalculate |
151 | | - } |
152 | | - |
153 | | - lastHeights = currentHeights.slice(); |
154 | | - |
155 | | - // Reset all items first |
156 | | - for (var i = 0; i < items.length; i++) { |
157 | | - items[i].style.gridRowEnd = 'auto'; |
158 | | - } |
159 | | - |
160 | | - // Force reflow |
161 | | - grid.offsetHeight; |
162 | | - |
163 | | - // Wait for content to settle, then calculate |
| 122 | +// Handle Instagram embeds when they're ready |
| 123 | +if (window.instgrm) { |
164 | 124 | setTimeout(function() { |
165 | | - for (var i = 0; i < items.length; i++) { |
166 | | - var rect = items[i].getBoundingClientRect(); |
167 | | - var itemHeight = rect.height; |
168 | | - |
169 | | - var rowSpan = Math.ceil((itemHeight + verticalGap) / rowHeight); |
170 | | - items[i].style.gridRowEnd = 'span ' + rowSpan; |
| 125 | + if (window.instgrm.Embeds) { |
| 126 | + window.instgrm.Embeds.process(); |
171 | 127 | } |
172 | | - }, 100); |
| 128 | + }, 1000); |
173 | 129 | } |
174 | 130 |
|
175 | | -// Initial load timing - less aggressive |
176 | | -setTimeout(applyMasonry, 500); |
177 | | -setTimeout(applyMasonry, 1500); |
178 | | -setTimeout(applyMasonry, 3000); |
179 | | -setTimeout(applyMasonry, 6000); |
180 | | - |
181 | | -window.addEventListener('resize', function() { |
182 | | - isStable = false; // Reset stability on resize |
183 | | - setTimeout(applyMasonry, 300); |
184 | | -}); |
185 | | - |
186 | | -// Handle Instagram embeds |
187 | | -function handleInstagramEmbeds() { |
| 131 | +setTimeout(function() { |
188 | 132 | if (window.instgrm && window.instgrm.Embeds) { |
189 | 133 | window.instgrm.Embeds.process(); |
190 | | - setTimeout(function() { |
191 | | - isStable = false; // Reset stability when Instagram loads |
192 | | - applyMasonry(); |
193 | | - }, 2000); |
194 | | - } |
195 | | -} |
196 | | - |
197 | | -setTimeout(handleInstagramEmbeds, 2000); |
198 | | -setTimeout(handleInstagramEmbeds, 5000); |
199 | | - |
200 | | -// Only check periodically if not stable, and less frequently |
201 | | -var periodicCheck = setInterval(function() { |
202 | | - if (!isStable && masonryAttempts < 20) { |
203 | | - applyMasonry(); |
204 | | - } else { |
205 | | - clearInterval(periodicCheck); |
206 | 134 | } |
207 | | -}, 5000); // Every 5 seconds instead of 2 |
| 135 | +}, 3000); |
208 | 136 | </script> |
209 | 137 |
|
210 | 138 | <script async src="https://www.instagram.com/embed.js"></script> |
0 commit comments