aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/public.ts
blob: ce4af8aa2ac0e27f77cbfef9df432a52094b4e4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

const body = document.body
const footer = document.querySelector('footer')
let prevHeight = footer?.offsetHeight

const onResize: ResizeObserverCallback = (entries) => {
	for (const entry of entries) {
		const height = entry.contentRect.height
		if (height === prevHeight) {
			return
		}
		prevHeight = height
		body.style.setProperty('--footer-height', `${height}px`)
	}
}

if (footer) {
	new ResizeObserver(onResize)
		.observe(footer, {
			box: 'border-box', // <footer> is border-box
		})
}