()
| 192 | let frame = 0; |
| 193 | // fallow-ignore-next-line complexity |
| 194 | const update = () => { |
| 195 | frame = requestAnimationFrame(update); |
| 196 | const iframe = iframeRef.current; |
| 197 | const overlayEl = overlayRef.current; |
| 198 | if (!iframe || !overlayEl) return; |
| 199 | const iRect = iframe.getBoundingClientRect(); |
| 200 | const oRect = overlayEl.getBoundingClientRect(); |
| 201 | const left = iRect.left - oRect.left; |
| 202 | const top = iRect.top - oRect.top; |
| 203 | if (iRect.width <= 0 || iRect.height <= 0) return; |
| 204 | const doc = iframe.contentDocument; |
| 205 | const root = doc?.querySelector<HTMLElement>("[data-composition-id]") ?? doc?.documentElement; |
| 206 | const dw = Number.parseFloat(root?.getAttribute("data-width") ?? ""); |
| 207 | const dh = Number.parseFloat(root?.getAttribute("data-height") ?? ""); |
| 208 | const scaleX = dw > 0 ? iRect.width / dw : 1; |
| 209 | const scaleY = dh > 0 ? iRect.height / dh : 1; |
| 210 | setCompRect((prev) => { |
| 211 | if ( |
| 212 | Math.abs(prev.left - left) < 0.5 && |
| 213 | Math.abs(prev.top - top) < 0.5 && |
| 214 | Math.abs(prev.width - iRect.width) < 0.5 && |
| 215 | Math.abs(prev.height - iRect.height) < 0.5 && |
| 216 | Math.abs(prev.scaleX - scaleX) < 0.001 && |
| 217 | Math.abs(prev.scaleY - scaleY) < 0.001 |
| 218 | ) |
| 219 | return prev; |
| 220 | return { left, top, width: iRect.width, height: iRect.height, scaleX, scaleY }; |
| 221 | }); |
| 222 | }; |
| 223 | frame = requestAnimationFrame(update); |
| 224 | return () => cancelAnimationFrame(frame); |
| 225 | }); |
nothing calls this directly
no test coverage detected