@zerolith/browser
Import from @zerolith/browser. Generated from the source; every signature below is what the published types declare.
Functions
size
function size(target: Element | ReadableSignal<Element | undefined>): ReadableSignal<Size>The content box of target as a signal: the element itself, or the
signal a ref fills, which measures the element it holds and is no size
while it holds none. An element not yet in the document is no size
until the observer first reports it. One ResizeObserver, shared by every
measured element, keeps the signal current; it stops with the enclosing
owner when there is one and lives for the page otherwise. Where there is
no observer, as on the server, the signal is no size.
Source: packages/browser/src/size.ts:91
inView
function inView(target: Element | ReadableSignal<Element | undefined>, options?: InViewOptions): ReadableSignal<boolean>Whether target intersects the viewport, as a signal: the element
itself, or the signal a ref fills, which follows the element it holds
and is false while it holds none. An IntersectionObserver keeps it
current; it stops with the enclosing owner when there is one and lives
for the page otherwise. The signal is false until the observer first
reports, and where there is no observer, as on the server. A threshold
outside 0 to 1, or a root margin the browser refuses, fails with
in_view_options_invalid.
Source: packages/browser/src/inview.ts:31
online
function online(): ReadableSignal<boolean>Whether the browser is online, as navigator.onLine says, following the online and offline events; one signal for the page, started when first asked for, and true where there is no browser.
Source: packages/browser/src/page.ts:27
visible
function visible(): ReadableSignal<boolean>Whether the page is visible, following visibilitychange; one signal for the page, started when first asked for, and true where there is no document.
Source: packages/browser/src/page.ts:34
windowSize
function windowSize(): ReadableSignal<Size>The window's inner size, following resize, which a browser fires once per frame; one signal for the page, started when first asked for, and no size where there is no window.
Source: packages/browser/src/page.ts:41
Interfaces
Size
interface SizeA width and a height in CSS pixels.
readonly width: number: The width in CSS pixels.readonly height: number: The height in CSS pixels.
Source: packages/browser/src/size.ts:7
InViewOptions
interface InViewOptionsOptions for inView.
rootMargin?: string: Space around the viewport that counts as in view, as an IntersectionObserver'srootMargin; "200px" starts loading a little ahead of the scroll.threshold?: number: How much of the element must show, from 0 for any part of it to 1 for all of it. Defaults to 0.
Source: packages/browser/src/inview.ts:7