evalstate HF Staff commited on
Commit
e4747bb
·
verified ·
1 Parent(s): 5aeaa78

Reduce iframe load jumpiness with fade-in and ready-state smoothing

Browse files
Files changed (1) hide show
  1. 2026/mcp-connect/presentation.html +51 -0
2026/mcp-connect/presentation.html CHANGED
@@ -1328,4 +1328,55 @@ video.full-slide {
1328
  }
1329
  })();
1330
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1331
  </body></html>
 
1328
  }
1329
  })();
1330
  </script>
1331
+
1332
+ <style id="iframe-smooth-load">
1333
+ iframe.demo {
1334
+ opacity: 0;
1335
+ transition: opacity 220ms ease;
1336
+ will-change: opacity;
1337
+ }
1338
+
1339
+ iframe.demo.is-ready {
1340
+ opacity: 1;
1341
+ }
1342
+ </style>
1343
+ <script>
1344
+ (function () {
1345
+ function markReady(iframe) {
1346
+ iframe.classList.add('is-ready');
1347
+ }
1348
+
1349
+ function initIframe(iframe) {
1350
+ if (!iframe || iframe.__smoothInit) return;
1351
+ iframe.__smoothInit = true;
1352
+
1353
+ iframe.addEventListener('load', () => {
1354
+ requestAnimationFrame(() => markReady(iframe));
1355
+ });
1356
+
1357
+ // Fallback: avoid staying hidden if load event timing is missed.
1358
+ setTimeout(() => markReady(iframe), 1200);
1359
+
1360
+ try {
1361
+ const doc = iframe.contentDocument;
1362
+ if (doc && doc.readyState === 'complete') {
1363
+ markReady(iframe);
1364
+ }
1365
+ } catch (_) {}
1366
+ }
1367
+
1368
+ function initAll() {
1369
+ document.querySelectorAll('iframe.demo').forEach(initIframe);
1370
+ }
1371
+
1372
+ if (document.readyState === 'complete') {
1373
+ initAll();
1374
+ } else {
1375
+ window.addEventListener('load', initAll, { once: true });
1376
+ }
1377
+
1378
+ const observer = new MutationObserver(initAll);
1379
+ observer.observe(document.body, { childList: true, subtree: true });
1380
+ })();
1381
+ </script>
1382
  </body></html>