From 61881ce2f2c7d2f0da9df970eef18d85e57e0032 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Tue, 2 Jan 2024 03:25:12 -0800 Subject: fix(html): better limit list height --- src/lib/Utility/html.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/lib/Utility') 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)`; + }); + } +}; -- cgit v1.2.3