ElementRect (element-rect/element-rect.svelte.ts)

runed · packages/runed/src/lib/utilities/element-rect/element-rect.svelte.ts · typescript · MIT
ui

Reactive element position and size tracker for Svelte 5 applications.

// Source: https://github.com/svecosystem/runed | License: MIT | Copyright 2024 Hunter Johnston <https://github.com/huntabyte>
// Provided via justclaw.it.com; keep this notice with the code.
import { extract } from "../extract/extract.svelte.js";
import { useMutationObserver } from "../use-mutation-observer/use-mutation-observer.svelte.js";
import { useResizeObserver } from "../use-resize-observer/use-resize-observer.svelte.js";
import type { MaybeElementGetter, WritableProperties } from "#lib/internal/types.js";
import type { ConfigurableWindow } from "#lib/internal/configurable-globals.js";

type Rect = WritableProperties<Omit<DOMRect, "toJSON">>;

export type ElementRectOptions = ConfigurableWindow & {
	initialRect?: DOMRect;
};

/**
 * Returns a reactive value holding the size of `nod

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key