timvir 0.2.32 → 0.2.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -217,22 +217,6 @@ function Viewport(props, ref) {
217
217
  setHeight(height);
218
218
  setMaxHeight(Math.max(height, maxHeight ?? 0));
219
219
  });
220
-
221
- /*
222
- * 20ms after the height has been set, we consider this block settled. This
223
- * time includes the 16ms CSS transition time, and a tiny bit more to allow
224
- * for the content in the iframe itself to finish rendering.
225
- */
226
- React.useEffect(() => {
227
- const timeoutId = setTimeout(() => {
228
- mutate(draft => {
229
- draft.settled = true;
230
- });
231
- }, 20);
232
- return () => {
233
- clearTimeout(timeoutId);
234
- };
235
- }, [mutate, height]);
236
220
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
237
221
  ref: containerRef
238
222
  }), /*#__PURE__*/React.createElement(Root, {
@@ -279,7 +263,7 @@ function Viewport(props, ref) {
279
263
  */
280
264
 
281
265
  const initializeDocument = () => {
282
- if (document.readyState === "interactive" || document.readyState === "complete") {
266
+ if (document.readyState === "complete") {
283
267
  /*
284
268
  * Inject a simple style reset into the document.
285
269
  */
@@ -303,6 +287,21 @@ function Viewport(props, ref) {
303
287
  * style reset into the iframe document).
304
288
  */
305
289
  iframeRO.observe(document.body);
290
+
291
+ /*
292
+ * 50ms after the iframe document is complete, we consider the Viewport block
293
+ * settled. This time includes the 16ms CSS transition time, and a tiny bit more
294
+ * to allow for the content in the iframe itself to finish rendering.
295
+ *
296
+ * This time is not quite enough if the iframe loads additional code or needs to
297
+ * load data from a remote source. But should be enough for statically rendered
298
+ * content.
299
+ */
300
+ setTimeout(() => {
301
+ mutate(draft => {
302
+ draft.settled = true;
303
+ });
304
+ }, 50);
306
305
  } else {
307
306
  document?.addEventListener("readystatechange", initializeDocument, {
308
307
  once: true
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "timvir",
4
- "version": "0.2.32",
4
+ "version": "0.2.33",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
7
7
  "exports": {