blob: e3aa5fede915cffc101de4e453c316ec37c3475d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
---
title: ResizeObserverEntry
slug: Web/API/ResizeObserverEntry
translation_of: Web/API/ResizeObserverEntry
---
<div>{{APIRef("Resize Observer API")}}{{SeeCompatTable}}</div>
<p class="summary"><strong><code>ResizeObserverEntry</code></strong> 接口是传递给{{domxref('ResizeObserver.ResizeObserver','ResizeObserver()')}} 构造器回调函数中的参数对象。</p>
<h2 id="属性">属性</h2>
<dl>
<dt>{{domxref('ResizeObserverEntry.contentRect')}} {{experimental_inline}} {{readonlyinline}}</dt>
<dd>对改变尺寸大小的元素的 {{domxref('DOMRectReadOnly')}}引用(包含x,y,width,height,top,right,bottom,left属性)。</dd>
<dt>{{domxref('ResizeObserverEntry.target')}} {{experimental_inline}} {{readonlyinline}}</dt>
<dd>当前改变尺寸大小的元素的 {{domxref('Element')}} 引用</dd>
<dt> </dt>
</dl>
<h3 id="事件">事件</h3>
<p>无</p>
<h2 id="方法">方法</h2>
<p>无.</p>
<h2 id="示例">示例</h2>
<p>以下示例通过观察box的宽度变化从而改变其边框圆角半径。</p>
<pre class="brush: js">const resizeOserver = new ResizeObserver(entries => {
for (let entry of entries) {
entry.target.style.borderRadius = Math.max(0, 250 - entry.contentRect.width) + 'px';
}
});
resizeObserver.observe(document.querySelector('.box:nth-child(2)'));</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('Resize Observer','#resize-observer-entry-interface','ResizeObserverEntry')}}</td>
<td>{{Spec2('Resize Observer')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.ResizeObserverEntry")}}</p>
|