I have a masonry grid with images inside a tab pane. It doesn’t initialize when the tabpane is toggled and is active, I need to actually scroll the page for it to initialize. If I put the same masonry outside of the tabpane, it works fine.
This is what I get when the tabpane is activated and becomes visible:
Component like masonry, google maps, swiper and others that rely on the height of the element they are placed into will always have issues with tabs, modals, collapses, initially hidden elements.
On page load these elements have a height of 0 as they have a style of display: none; applied.
In your case, your tab 2 is hidden on page load and masonry component doesn’t know what its height is. You need to “refresh” the masonry component on tab show.
Example code, that will do the job:
<script>
$('#navTabs1_2_tab').on('shown.bs.tab', function (e) {
dmx.parse("masonry1.reflow()")
});
</script>
Where:
#navTabs1_2_tab is the ID of the nav tab button (note - not the tab content id!)