Skip to content

Commit

Permalink
Improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Aug 22, 2022
1 parent 97ff9ad commit 3101946
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {

function resizeHeight() {
if ( ! timeoutId ) {
// Throttle the updates on timeout.
// Throttle the updates on timeout. This code previously
// used `requestAnimationFrame`, but that seems to not
// always work before an iframe is ready.
timeoutId = iframe.contentWindow.setTimeout( () => {
const { readyState } = iframe.contentDocument;

Expand All @@ -77,7 +79,9 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {

setHeight( iframe.contentDocument.body.scrollHeight );
timeoutId = null;
}, 40 );

// 30 frames per second.
}, 1000 / 30 );
}
}

Expand All @@ -89,8 +93,9 @@ function ResizableEditor( { enableResizing, settings, children, ...props } ) {
resizeObserver = new iframe.contentWindow.ResizeObserver(
resizeHeight
);
// Observing the <html> rather than the <body> because the latter
// gets destroyed and remounted after initialization in <Iframe>.

// Observe the body, since the `html` element seems to always
// have a height of `100%`.
resizeObserver.observe( iframe.contentDocument.body );

resizeHeight();
Expand Down

0 comments on commit 3101946

Please sign in to comment.