diff options
| author | Fuwn <[email protected]> | 2024-01-02 03:25:12 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-02 03:25:12 -0800 |
| commit | 61881ce2f2c7d2f0da9df970eef18d85e57e0032 (patch) | |
| tree | 4d1409145fe60d6ec428d5ccaf01aa263a9d35ee /src/lib | |
| parent | refactor(lastactivity): move info to component (diff) | |
| download | due.moe-61881ce2f2c7d2f0da9df970eef18d85e57e0032.tar.xz due.moe-61881ce2f2c7d2f0da9df970eef18d85e57e0032.zip | |
fix(html): better limit list height
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)`; + }); + } +}; |