diff options
| author | Fuwn <[email protected]> | 2024-10-09 00:41:20 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-09 00:41:43 -0700 |
| commit | 998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch) | |
| tree | 50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/lib/Utility/html.ts | |
| parent | feat(graphql): add badgeCount field (diff) | |
| download | due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip | |
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/lib/Utility/html.ts')
| -rw-r--r-- | src/lib/Utility/html.ts | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/lib/Utility/html.ts b/src/lib/Utility/html.ts index 9dc16634..8d60d3b6 100644 --- a/src/lib/Utility/html.ts +++ b/src/lib/Utility/html.ts @@ -4,39 +4,39 @@ import { get } from 'svelte/store'; export const nbsp = (str: string) => str.replace(/ /g, ' '); export const createHeightObserver = (details = true) => { - document.querySelectorAll('.list').forEach((element) => { - if ( - !( - element as unknown as { - dataset: { observed: string }; - } - ).dataset.observed - ) { - new ResizeObserver((entries) => { - entries.forEach((entry) => { - const element = entry.target as HTMLElement; - - if (get(settings).displayLimitListHeight) { - element.style.height = 'auto'; - - const elementBound = element.getBoundingClientRect(); - const height = window.innerHeight - elementBound.top - 2.5 * 16; - - if (elementBound.height > height) element.style.height = `${height}px`; - } - }); - }).observe(element); - - if (details) - new MutationObserver((mutations) => { - mutations.forEach((mutation) => { - const element = mutation.target as HTMLDetailsElement; - - if (element.tagName === 'DETAILS' && !element.open) element.style.height = 'auto'; - }); - }).observe(element, { attributes: true }); - - element.setAttribute('data-observed', 'true'); - } - }); + document.querySelectorAll('.list').forEach((element) => { + if ( + !( + element as unknown as { + dataset: { observed: string }; + } + ).dataset.observed + ) { + new ResizeObserver((entries) => { + entries.forEach((entry) => { + const element = entry.target as HTMLElement; + + if (get(settings).displayLimitListHeight) { + element.style.height = 'auto'; + + const elementBound = element.getBoundingClientRect(); + const height = window.innerHeight - elementBound.top - 2.5 * 16; + + if (elementBound.height > height) element.style.height = `${height}px`; + } + }); + }).observe(element); + + if (details) + new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + const element = mutation.target as HTMLDetailsElement; + + if (element.tagName === 'DETAILS' && !element.open) element.style.height = 'auto'; + }); + }).observe(element, { attributes: true }); + + element.setAttribute('data-observed', 'true'); + } + }); }; |