Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dt-assets/js/details.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/*
global ResizeObserver
*/
'use strict';
jQuery(document).ready(function ($) {
let post_id = window.detailsSettings.post_id;
Expand Down Expand Up @@ -1249,6 +1252,22 @@ jQuery(document).ready(function ($) {
service.initialize();
window.componentService = service;
}

// When components are resized, re-layout the masonry grid
const targetElement = document.querySelectorAll('.grid .bordered-box .cell');
let resizeTimeout;
const resizeObserver = new ResizeObserver((entries) => {
for (let entry of entries) {
// many of these can be triggered on initial load, so debounce them with a timeout
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
window.masonGrid.masonry('layout');
}, 100);
}
});
for (let element of targetElement) {
resizeObserver.observe(element);
}
});

// change update needed notification and switch if needed.
Expand Down
Loading