blob: d1e506f661ec9db8600c2718c6ee75edba01661a (
plain) (
blame)
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
27
28
29
30
31
32
|
import settings from '$stores/settings';
import { get } from 'svelte/store';
export const nbsp = (str: string) => str.replace(/ /g, ' ');
export const limitListHeight = () => {
if (get(settings).displayLimitListHeight) {
let tallestList: HTMLElement | undefined;
document.querySelectorAll('.list').forEach((list) => {
const element = list as HTMLElement;
element.style.height = 'auto';
if (element.offsetHeight > (tallestList ? tallestList.offsetHeight : 0))
tallestList = element;
});
if (tallestList)
tallestList.style.maxHeight = `calc(${window.innerHeight}px - ${
document.querySelector('#header')?.getBoundingClientRect().bottom || 0
}px - 4rem)`;
}
};
export const createHeightObserver = () => {
const observer = new ResizeObserver(() => limitListHeight());
document.querySelectorAll('#list-container').forEach((element) => {
observer.observe(element);
});
};
|