Skip to content

Latest commit

 

History

History

window-sizes

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

helcor

@helcor/window-sizes

version downloads

Browser window dimensions and sizes manipulation.

getElementHeight

Get an HTMLElement content height or a provided window body content height in pixels.

API

import { getElementHeight } from '@helcor/window-sizes';
getElementHeight(element: HTMLElement | Window): number

Examples

// Get the window body content height.
const height = getElementHeight(window);

// Get an element content height.
const element = document.querySelector('#element-id');
const height = getElementHeight(element);

getViewportSize

Get the browser viewport width and height in pixels.

API

import { getViewportSize } from '@helcor/window-sizes';
getViewportSize(
  { wMin, wMax, hMin, hMax }: { wMin: number, wMax: number, hMin: number, hMax: number } = {},
  defaultSize: { width: number, height: number }
): { width: number, height: number }

Example

// Get the raw browser viewport.
const { width, height } = getViewportSize();

// Get the raw browser viewport with minimum of 800x600 pixels.
const { width, height } = getViewportSize({ wMin: 800, hMin: 600 });