@@ -87,15 +87,15 @@ ResizeObserver's notifications can be used to respond to changes in {{Element}}'
8787
8888<div class="example">
8989 <pre highlight="html">
90- <canvas id="elipse " style="display:block"></canvas>
90+ <canvas id="ellipse " style="display:block"></canvas>
9191 <div id="menu" style="display:block;width:100px">
9292 <img src="hamburger.jpg" style="width:24px;height:24px">
9393 <p class="title">menu title</p>
9494 </div>
9595 </pre>
9696 <pre highlight="js">
97- // In response to resize, elipse paints an elipse inside a canvas
98- document.querySelector('#elipse ' ).handleResize = entry => {
97+ // In response to resize, paint an ellipse inside a canvas
98+ document.querySelector('#ellipse ' ).handleResize = entry => {
9999 entry.target.width = entry.borderBoxSize[0] .inlineSize;
100100 entry.target.height = entry.borderBoxSize[0] .blockSize;
101101 let rx = Math.floor(entry.target.width / 2);
@@ -105,28 +105,30 @@ ResizeObserver's notifications can be used to respond to changes in {{Element}}'
105105 ctx.ellipse(rx, ry, rx, ry, 0, 0, 2 * Math.PI);
106106 ctx.stroke();
107107 }
108+
108109 // In response to resize, change title visibility depending on width
109110 document.querySelector('#menu' ).handleResize = entry => {
110- let title = entry.target.querySelector(" .title")
111+ let title = entry.target.querySelector(' .title' );
111112 if (entry.borderBoxSize[0] .inlineSize < 40)
112- title.style.display = " none" ;
113+ title.style.display = ' none' ;
113114 else
114- title.style.display = " inline-block" ;
115+ title.style.display = ' inline-block' ;
115116 }
116117
117- var ro = new ResizeObserver( entries => {
118+ let ro = new ResizeObserver(entries => {
118119 for (let entry of entries) {
119120 let cs = window.getComputedStyle(entry.target);
120121 console.log('watching element:' , entry.target);
121- console.log(entry.contentRect.top,' is ' , cs.paddingTop);
122- console.log(entry.contentRect.left,' is ' , cs.paddingLeft);
123- console.log(entry.borderBoxSize[0] .inlineSize,' is ' , cs.width);
124- console.log(entry.borderBoxSize[0] .blockSize,' is ' , cs.height);
122+ console.log(entry.contentRect.top, ' is ' , cs.paddingTop);
123+ console.log(entry.contentRect.left, ' is ' , cs.paddingLeft);
124+ console.log(entry.borderBoxSize[0] .inlineSize, ' is ' , cs.width);
125+ console.log(entry.borderBoxSize[0] .blockSize, ' is ' , cs.height);
125126 if (entry.target.handleResize)
126127 entry.target.handleResize(entry);
127128 }
128129 });
129- ro.observe(document.querySelector('#elipse' ));
130+
131+ ro.observe(document.querySelector('#ellipse' ));
130132 ro.observe(document.querySelector('#menu' ));
131133 </pre>
132134</div>
0 commit comments