DOMMatrixReadOnly:isIdentity 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流瀏覽器均已支援。

注意:此功能在 Web Workers 中可用。

DOMMatrixReadOnly 介面的只讀 isIdentity 屬性是一個布林值,如果矩陣是單位矩陣,則該屬性值為 true

單位矩陣是一種矩陣,其中所有值都為 0除了從左上角到右下角的主對角線上的值(換句話說,每個方向上的偏移量都相等)。

一個布林值。

示例

js
// Initialize a 2D matrix
const matrix = new DOMMatrix(); // create a matrix
console.log(matrix.isIdentity); // output: true

// Apply a transform that has no effect
console.log(matrix.translate(0).isIdentity); // output: true

// Apply a transform with effect: this rotates the matrix by 30deg
console.log(matrix.rotate(30).isIdentity); // output: false

規範

規範
Geometry Interfaces Module Level 1
# dom-dommatrixreadonly-isidentity

瀏覽器相容性

另見