Skip to content

Instantly share code, notes, and snippets.

View matomesc's full-sized avatar

Mihai Tomescu matomesc

View GitHub Profile
@matomesc
matomesc / getMaxHeight.ts
Last active October 16, 2023 19:02
Get the maximum height an element can be to fill the viewport
/**
* Get the maximum height an element can be to fill the viewport.
*
* @param el
* @returns
*/
function getMaxHeight(el: HTMLElement) {
function pageY(elem: HTMLElement): number {
return elem.offsetParent
? elem.offsetTop + pageY(elem.offsetParent as HTMLElement)
@matomesc
matomesc / index.ts
Created October 16, 2023 22:22
Get a css property value
const fontSize = window
.getComputedStyle(element)
.getPropertyValue('font-size');