DOMPoint.DOMPoint()

DOMPoint()构造函数创建并返回一个 DOMPoint 对象,可提供部分或全部属性值作为其参数。

也可以通过调用静态方法 DOMPoint.fromPoint() 来创建 DOMPoint 。此方法接受一个 DOMPointInit 兼容对象(DOMPoint 或 DOMPointReadOnly)作为参数 。

语法

point = new DOMPoint(x, y, z, w);

参数

x 可选
x 坐标。
y 可选
y 坐标。
z 可选
z 坐标。
w 可选
透视值。

示例

示例首先创建了一个表示当前窗口左上角的 DOMPoint ,接着根据第一个点创建一个新的 DOMPoint 并将其在垂直和水平方向上偏移100px。

var windTopLeft = new DOMPoint(window.screenX, window.screenY);
var newTopLeft = DOMPoint.fromPoint(windTopLeft);
newTopLeft.x += 100;
newTopLeft.y += 100;

规范

Specification Status Comment
Geometry Interfaces Module Level 1
DOMPoint()
Candidate Recommendation Initial definition

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
DOMPoint() constructor
Experimental
Chrome Full support 61Edge Full support 79Firefox Full support 31IE No support NoOpera Full support 48Safari Full support 10.1WebView Android Full support 61Chrome Android Full support 61Firefox Android Full support 31Opera Android Full support 45Safari iOS Full support 10.3Samsung Internet Android Full support 8.0

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

相关链接