DOMRect
Draft: This page is not complete.
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, VREyeParameters.renderRect
from the WebVR API specifies the viewport of a canvas into which visuals for one eye of a head mounted display should be rendered.
It inherits from its parent, DOMRectReadOnly
.
Constructor
DOMRect()
-
Creates a new
DOMRect
object.
Properties
DOMRect
inherits properties from its parent, DOMRectReadOnly
. The difference is that they are not read-only anymore.
DOMRectReadOnly.x
-
The x coordinate of the
DOMRect
's origin (typically the top-left corner of the rectangle). DOMRectReadOnly.y
-
The y coordinate of the
DOMRect
's origin (typically the top-left corner of the rectangle). DOMRectReadOnly.width
-
The width of the
DOMRect
. DOMRectReadOnly.height
-
The height of the
DOMRect
. DOMRectReadOnly.top
-
Returns the top coordinate value of the
DOMRect
(has the same value asy
, ory + height
ifheight
is negative.) DOMRectReadOnly.right
-
Returns the right coordinate value of the
DOMRect
(has the same value asx + width
, orx
ifwidth
is negative.) DOMRectReadOnly.bottom
-
Returns the bottom coordinate value of the
DOMRect
(has the same value asy + height
, ory
ifheight
is negative.) DOMRectReadOnly.left
-
Returns the left coordinate value of the
DOMRect
(has the same value asx
, orx + width
ifwidth
is negative.)
Methods
DOMRect
inherits methods from its parent, DOMRectReadOnly
.
Static methods
DOMRectReadOnly.fromRect()
-
Creates a new
DOMRect
object with a given location and dimensions.
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
DOMRect |
61
2-61
|
79
12-79
|
27
3-27
|
4 |
48
9.5-48
|
10.1
4-11
|
61
2-61
|
61
18-61
|
27
4-27
|
45
10.1-45
|
10.3
3.2-11
|
8.0
1.0-8.0
|
DOMRect |
61 |
79 |
31 |
No |
48 |
10.1 |
61 |
61 |
31 |
45 |
10.3 |
8.0 |
fromRect |
61 |
79 |
69 |
No |
48 |
10.1 |
61 |
61 |
79 |
45 |
10.3 |
8.0 |
height |
2 |
12 |
3 |
4 |
9.5 |
4 |
2 |
18 |
4 |
10.1 |
3.2 |
1.0 |
width |
2 |
12 |
3 |
4 |
9.5 |
4 |
2 |
18 |
4 |
10.1 |
3.2 |
1.0 |
worker_support |
61 |
79 |
69 |
No |
48 |
10.1 |
61 |
61 |
No |
45 |
10.3 |
8.0 |
x |
61 |
79 |
31 |
No |
48 |
10.1 |
61 |
61 |
31 |
45 |
10.3 |
8.0 |
y |
61 |
79 |
31 |
No |
48 |
10.1 |
61 |
61 |
31 |
45 |
10.3 |
8.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DOMRect