public.ts 625 B

1234567891011121314151617181920212223242526
  1. /**
  2. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: AGPL-3.0-or-later
  4. */
  5. const body = document.body
  6. const footer = document.querySelector('footer')
  7. let prevHeight = footer?.offsetHeight
  8. const onResize: ResizeObserverCallback = (entries) => {
  9. for (const entry of entries) {
  10. const height = entry.contentRect.height
  11. if (height === prevHeight) {
  12. return
  13. }
  14. prevHeight = height
  15. body.style.setProperty('--footer-height', `${height}px`)
  16. }
  17. }
  18. if (footer) {
  19. new ResizeObserver(onResize)
  20. .observe(footer, {
  21. box: 'border-box', // <footer> is border-box
  22. })
  23. }