diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/Utility/html.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/Utility/html.ts b/src/lib/Utility/html.ts index 6d2136aa..01041b0e 100644 --- a/src/lib/Utility/html.ts +++ b/src/lib/Utility/html.ts @@ -1 +1,23 @@ +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) { + document.querySelectorAll('.list').forEach((list) => { + const listContainerBottom = + document.querySelector('#list-container')?.getBoundingClientRect().bottom || 0; + const headerBottom = document.querySelector('#header')?.getBoundingClientRect().bottom || 0; + const offset = 1.25; + const offsetInPixels = + offset * parseFloat(getComputedStyle(document.documentElement).fontSize); + + ( + list as HTMLElement + ).style.maxHeight = `calc(100vh - ${listContainerBottom}px + ${headerBottom}px - ${ + offsetInPixels * 2 + }px)`; + }); + } +}; |