DOMPoint.DOMPoint()
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.
**DOMPoint()
**构造函数创建并返回一个 DOMPoint
对象,可提供部分或全部属性值作为其参数。
也可以通过调用静态方法 DOMPoint.fromPoint()
来创建 DOMPoint
。此方法接受一个 DOMPointInit
兼容对象(DOMPoint
或 DOMPointReadOnly
)作为参数。
语法
point = new DOMPoint(x, y, z, w);
参数
示例
示例首先创建了一个表示当前窗口左上角的 DOMPoint
,接着根据第一个点创建一个新的 DOMPoint
并将其在垂直和水平方向上偏移 100px。
js
var windTopLeft = new DOMPoint(window.screenX, window.screenY);
var newTopLeft = DOMPoint.fromPoint(windTopLeft);
newTopLeft.x += 100;
newTopLeft.y += 100;
规范
Specification |
---|
Geometry Interfaces Module Level 1 # dom-dompoint-dompoint |
浏览器兼容性
BCD tables only load in the browser