mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 01:29:54 -06:00
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user