Skip to content

galavi / normalizeDrag

Function: normalizeDrag()

normalizeDrag(rawDx, rawDy, canvasWidth, canvasHeight): object

Defined in: utils/input.ts:64

Normalize a pointer drag delta from raw pixels to viewport-fraction units.

Returns { dx, dy } where 1.0 = full canvas dimension. Accounts for devicePixelRatio so behavior is consistent across HiDPI screens.

Parameters

rawDx

number

rawDy

number

canvasWidth

number

canvasHeight

number

Returns

object

dx

dx: number

dy

dy: number

Released under the GPL-3.0 License.