DOMRect
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Geometry Interfaces")}}{{AvailableInWorkers}}
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, {{domxref("Range.getBoundingClientRect()")}} specifies the rectangle that bounds the content of the range using such objects.
It inherits from its parent, {{domxref("DOMRectReadOnly")}}.
{{InheritanceDiagram}}
Constructor
- {{domxref("DOMRect.DOMRect","DOMRect()")}}
- : Creates a new
DOMRectobject.
Instance properties
_DOMRect inherits properties from its parent, {{domxref("DOMRectReadOnly")}}. The difference is that they are not read-only anymore._
- {{domxref("DOMRect.x")}}
- : The x coordinate of the
DOMRect's origin (typically the top-left corner of the rectangle). - {{domxref("DOMRect.y")}}
- : The y coordinate of the
DOMRect's origin (typically the top-left corner of the rectangle). - {{domxref("DOMRect.width")}}
- : The width of the
DOMRect. - {{domxref("DOMRect.height")}}
- : The height of the
DOMRect. - {{domxref("DOMRectReadOnly.top")}} {{ReadOnlyInline}}
- : Returns the top coordinate value of the
DOMRect(has the same value asy, ory + heightifheightis negative). - {{domxref("DOMRectReadOnly.right")}} {{ReadOnlyInline}}
- : Returns the right coordinate value of the
DOMRect(has the same value asx + width, orxifwidthis negative). - {{domxref("DOMRectReadOnly.bottom")}} {{ReadOnlyInline}}
- : Returns the bottom coordinate value of the
DOMRect(has the same value asy + height, oryifheightis negative). - {{domxref("DOMRectReadOnly.left")}} {{ReadOnlyInline}}
- : Returns the left coordinate value of the
DOMRect(has the same value asx, orx + widthifwidthis negative).
Static methods
_DOMRect may also inherit static methods from its parent, {{domxref("DOMRectReadOnly")}}._
- {{domxref("DOMRect/fromRect_static", "DOMRect.fromRect()")}}
- : Creates a new
DOMRectobject with a given location and dimensions.
Instance methods
_DOMRect may inherit methods from its parent, {{domxref("DOMRectReadOnly")}}._
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{domxref("DOMPoint")}}