LayoutShiftAttribution: previousRect property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Thuộc tính chỉ đọc previousRect của giao diện LayoutShiftAttribution trả về một đối tượng DOMRectReadOnly đại diện cho vị trí của phần tử trước khi dịch chuyển.
Giá trị
Một đối tượng DOMRectReadOnly.
Ví dụ
Ví dụ sau in previousRect của phần tử đầu tiên trong LayoutShift.sources vào bảng điều khiển.
js
new PerformanceObserver((list) => {
for (const { sources } of list.getEntries()) {
if (sources) {
console.log(sources[0].previousRect);
}
}
}).observe({ type: "layout-shift", buffered: true });
Thông số kỹ thuật
| Specification |
|---|
| Layout Instability API> # dom-layoutshiftattribution-previousrect> |