Skip to content

Write HTML. Render video. Built for agents.

fix(registry): vfx-iphone-device stops gating its screens on rAF (#4083)

Miguel Ángel81ca5f418785
diff --git a/registry/blocks/vfx-iphone-device/vfx-iphone-device.html b/registry/blocks/vfx-iphone-device/vfx-iphone-device.html
index f48fa9e02a..9686df2cf6 100644
--- a/registry/blocks/vfx-iphone-device/vfx-iphone-device.html
+++ b/registry/blocks/vfx-iphone-device/vfx-iphone-device.html
@@ -626,14 +626,31 @@
if (ready === 2) onReady();
});
+ function waitForPaint(canvas) {
+ return new Promise(function (resolvePaint) {
+ if (!canvas || typeof canvas.requestPaint !== "function") {
+ resolvePaint();
+ return;
+ }
+ var resolved = false;
+ function done() {
+ if (resolved) return;
+ resolved = true;
+ canvas.onpaint = null;
+ resolvePaint();
+ }
+ canvas.onpaint = done;
+ canvas.requestPaint();
+ setTimeout(done, 100);
+ });
+ }
+
function onReady() {
- requestAnimationFrame(function () {
- requestAnimationFrame(function () {
- paintReady = true;
- captureScreens();
- window.__timelines = window.__timelines || {};
- window.__timelines["devices-canvas"] = tl;
- });
+ Promise.all([waitForPaint(capPhoneCvs), waitForPaint(capLapCvs)]).then(function () {
+ paintReady = true;
+ captureScreens();
+ window.__timelines = window.__timelines || {};
+ window.__timelines["devices-canvas"] = tl;
});
}