Skip to main content

@rtorcato/browser-common / screen

screen

Functions​

getScreenWidth()​

getScreenWidth(): number | undefined

Defined in: screen/index.ts:10

Gets the current screen width in pixels.

Example​

import { getScreenWidth } from '@rtorcato/browser-common/screen'
const w = getScreenWidth()

Returns​

number | undefined

The screen width, or undefined if not in a browser.


getScreenHeight()​

getScreenHeight(): number | undefined

Defined in: screen/index.ts:26

Gets the current screen height in pixels.

Example​

import { getScreenHeight } from '@rtorcato/browser-common/screen'
const h = getScreenHeight()

Returns​

number | undefined

The screen height, or undefined if not in a browser.


getViewportWidth()​

getViewportWidth(): number | undefined

Defined in: screen/index.ts:42

Gets the current viewport width in pixels.

Example​

import { getViewportWidth } from '@rtorcato/browser-common/screen'
const w = getViewportWidth()

Returns​

number | undefined

The viewport width, or undefined if not in a browser.


getViewportHeight()​

getViewportHeight(): number | undefined

Defined in: screen/index.ts:58

Gets the current viewport height in pixels.

Example​

import { getViewportHeight } from '@rtorcato/browser-common/screen'
const h = getViewportHeight()

Returns​

number | undefined

The viewport height, or undefined if not in a browser.


isLandscape()​

isLandscape(): boolean | undefined

Defined in: screen/index.ts:74

Checks if the screen is currently in landscape orientation.

Example​

import { isLandscape } from '@rtorcato/browser-common/screen'
if (isLandscape()) renderWide()

Returns​

boolean | undefined

True if landscape, false if portrait, undefined if not in a browser.


isPortrait()​

isPortrait(): boolean | undefined

Defined in: screen/index.ts:90

Checks if the screen is currently in portrait orientation.

Example​

import { isPortrait } from '@rtorcato/browser-common/screen'
if (isPortrait()) renderStacked()

Returns​

boolean | undefined

True if portrait, false if landscape, undefined if not in a browser.


enterFullscreen()​

enterFullscreen(element?): Promise<void> | undefined

Defined in: screen/index.ts:107

Requests the browser to enter fullscreen mode for a given element.

Example​

import { enterFullscreen } from '@rtorcato/browser-common/screen'
button.addEventListener('click', () => enterFullscreen())

Parameters​

element?​

HTMLElement

The element to make fullscreen (defaults to document.documentElement).

Returns​

Promise<void> | undefined

A promise that resolves when fullscreen is entered, or undefined if not supported.


exitFullscreen()​

exitFullscreen(): Promise<void> | undefined

Defined in: screen/index.ts:126

Exits fullscreen mode if currently active.

Example​

import { exitFullscreen } from '@rtorcato/browser-common/screen'
await exitFullscreen()

Returns​

Promise<void> | undefined

A promise that resolves when fullscreen is exited, or undefined if not supported.


isFullscreen()​

isFullscreen(): boolean | undefined

Defined in: screen/index.ts:142

Checks if the browser is currently in fullscreen mode.

Example​

import { isFullscreen } from '@rtorcato/browser-common/screen'
if (isFullscreen()) showExitHint()

Returns​

boolean | undefined

True if in fullscreen, false otherwise, or undefined if not in a browser.