Skip to main content

@rtorcato/browser-common / viewtransitions

viewtransitions

Functions

isViewTransitionsSupported()

isViewTransitionsSupported(): boolean

Defined in: viewtransitions/index.ts:10

Checks if the View Transitions API is supported in the current environment.

Example

import { isViewTransitionsSupported } from '@rtorcato/browser-common/viewtransitions'
if (isViewTransitionsSupported()) enableFancyTransitions()

Returns

boolean

True if document.startViewTransition exists, false otherwise.


startViewTransition()

startViewTransition(updateCallback): Promise<void>

Defined in: viewtransitions/index.ts:26

Runs a DOM update inside a view transition when supported, otherwise runs it directly. Always resolves once the update callback has completed, so callers never need to branch on support.

Example

import { startViewTransition } from '@rtorcato/browser-common/viewtransitions'
await startViewTransition(() => updateDOM())

Parameters

updateCallback

() => void | Promise<void>

The DOM-mutating callback to run.

Returns

Promise<void>

A promise that resolves when the update has been applied.