DOMPoint: DOMPoint() constructor
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available in Web Workers.
The DOMPoint()
constructor
creates and returns a new DOMPoint
object, given the values for some or
all of its properties.
You can also create a DOMPoint
by calling the
DOMPoint.fromPoint()
static function. That function accepts any object with the required parameters, including a DOMPoint
or
DOMPointReadOnly
.
Syntax
new DOMPoint()
new DOMPoint(x)
new DOMPoint(x, y)
new DOMPoint(x, y, z)
new DOMPoint(x, y, z, w)
Parameters
x
Optional-
The
x
coordinate for the newDOMPoint
. y
Optional-
The
y
coordinate for the newDOMPoint
. z
Optional-
The
z
coordinate for the newDOMPoint
. w
Optional-
The perspective value of the new
DOMPoint
.
Examples
This example creates a DOMPoint
representing the top-left corner of the
current window, then creates a second point based on the first, which is then offset by
100 pixels both vertically and horizontally.
const windTopLeft = new DOMPoint(window.screenX, window.screenY);
const newTopLeft = DOMPoint.fromPoint(windTopLeft);
newTopLeft.x += 100;
newTopLeft.y += 100;
Specifications
Specification |
---|
Geometry Interfaces Module Level 1 # dom-dompoint-dompoint |
Browser compatibility
BCD tables only load in the browser