DOMRect

interface · experimental

interface DOMRect extends DOMRectReadOnly

A DOMRect describes the size and position of a rectangle.

MDN

variable · experimental

var DOMRect: { … }

A DOMRect describes the size and position of a rectangle.

MDN

Constructors

constructor

new DOMRect(x?: number, y?: number, width?: number, height?: number): DOMRect

Properties

height

height: number

The height property of the DOMRect interface represents the height of the rectangle. The value can be negative.

MDN Reference

width

width: number

The width property of the DOMRect interface represents the width of the rectangle. The value can be negative.

MDN Reference

x

x: number

The x property of the DOMRect interface represents the x-coordinate of the rectangle, which is the horizontal distance between the viewport's left edge and the rectangle's origin.

MDN Reference

y

y: number

The y property of the DOMRect interface represents the y-coordinate of the rectangle, which is the vertical distance between the viewport's top edge and the rectangle's origin.

MDN Reference

prototype

prototype: DOMRect

Methods

fromRect

fromRect(other?: DOMRectInit): DOMRect

The fromRect() static method of the DOMRect object creates a new DOMRect object with a given location and dimensions.

MDN Reference