feat: implement resize listener for fillAvailableHeight function

- Added a resize event listener to the fillAvailableHeight function in BodyInlineJS.php to ensure dynamic height adjustments on window resize.
- Implemented a debounced handler to optimize performance and prevent excessive function calls during rapid resize events.
- This enhancement improves the responsiveness of the layout by maintaining appropriate element heights as the window size changes.
This commit is contained in:
Zack Spear
2025-06-27 12:20:52 -07:00
parent bb87d4d370
commit dde0cd1f08

View File

@@ -538,5 +538,19 @@ function fillAvailableHeight(params = { // default params
targetHeight -= params.manualSpacingOffset || 10;
$(params.targetElementSelector).height(Math.max(targetHeight, minHeight));
// Set up resize listener to call itself with same params
// Remove existing listener first to avoid duplicates
if (window.fillAvailableHeightResizeHandler) {
window.removeEventListener('resize', window.fillAvailableHeightResizeHandler);
}
// Create debounced handler that calls this function with same params
window.fillAvailableHeightResizeHandler = debounce(function() {
fillAvailableHeight(params);
}, 150);
// Add the new listener
window.addEventListener('resize', window.fillAvailableHeightResizeHandler);
}
</script>