@helcor/window-sizes

1.0.0-beta.9 • Public • Published

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 });

Readme

Keywords

none

Package Sidebar

Install

npm i @helcor/window-sizes

Weekly Downloads

4

Version

1.0.0-beta.9

License

MIT

Unpacked Size

8.65 kB

Total Files

6

Last publish

Collaborators

  • romelperez