getOffset

Commons
stable

Computes the vector difference between two 2-D points (a − b) and returns it as a TOffset {x, y}. Used internally for drag-and-drop and overlay positioning.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

a
required
T
The origin point (minuend). Must have x and y numeric properties.
b
required
T
The reference point (subtrahend). Must have x and y numeric properties.

API

Return value

The value returned by this util.

A TOffset object { x: a.x − b.x, y: a.y − b.y } describing the displacement from b to a.

Usage

Examples

Ready-to-paste usage snippets.

Compute drag delta between pointer events

typescript