LayoutShiftAttribution: currentRect property

Khả dụng hạn chế

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 currentRect 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ử sau khi dịch chuyển.

Giá trị

Một đối tượng DOMRectReadOnly.

Ví dụ

Ví dụ sau in currentRect 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].currentRect);
    }
  }
}).observe({ type: "layout-shift", buffered: true });

Thông số kỹ thuật

Thông số kỹ thuật
Layout Instability API
# dom-layoutshiftattribution-currentrect

Tương thích trình duyệt