Function positionRelative

Returns relative position of element in target coordinate space, or viewport by default. Relative means that { x:0.5, y: 0.5 } is the middle of the target space. Eg for viewport, that means its the middle of the browser window.

// These all yield { x, y }
elPositionRelative('#blah');
elPositionRelative(evt.target, 'screen');
  • Parameters

    • domQueryOrEl: Readonly<string | HTMLElement>

      DOM query or element

    • target: PointSpaces = ...

      Target coordinate space, or viewport by default

    Returns Point

    Point