web api interface
DOMRect
Available in workers
A DOMRect describes the size and position of a rectangle.
The type of box represented by the DOMRect is specified by the method or property that returned it. For example, getBoundingClientRect() specifies the rectangle that bounds the content of the range using such objects.
It inherits from its parent, DOMRectReadOnly.
Constructor
DOMRect()- : Creates a new
DOMRectobject.
- : Creates a new
Instance properties
DOMRect inherits properties from its parent, DOMRectReadOnly. The difference is that they are not read-only anymore.
x- : The x coordinate of the
DOMRect’s origin (typically the top-left corner of the rectangle).
- : The x coordinate of the
y- : The y coordinate of the
DOMRect’s origin (typically the top-left corner of the rectangle).
- : The y coordinate of the
width- : The width of the
DOMRect.
- : The width of the
height- : The height of the
DOMRect.
- : The height of the
top- : Returns the top coordinate value of the
DOMRect(has the same value asy, ory + heightifheightis negative).
- : Returns the top coordinate value of the
right- : Returns the right coordinate value of the
DOMRect(has the same value asx + width, orxifwidthis negative).
- : Returns the right coordinate value of the
bottom- : Returns the bottom coordinate value of the
DOMRect(has the same value asy + height, oryifheightis negative).
- : Returns the bottom coordinate value of the
left- : Returns the left coordinate value of the
DOMRect(has the same value asx, orx + widthifwidthis negative).
- : Returns the left coordinate value of the
Static methods
DOMRect may also inherit static methods from its parent, DOMRectReadOnly.
DOMRect.fromRect()- : Creates a new
DOMRectobject with a given location and dimensions.
- : Creates a new
Instance methods
DOMRect may inherit methods from its parent, DOMRectReadOnly.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.