From 2246728c80b36cc6b59630c52e082ae810c12cb9 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 2 Mar 2017 12:27:31 -0700 Subject: [PATCH 1/2] only trigger a re-flow when the height actually changes --- client/coral-embed/src/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index d3715b44d..d3a6a4ee5 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -31,13 +31,14 @@ function buildStreamIframeUrl(talkBaseUrl, asset_url, comment, asset_id) { function configurePymParent(pymParent, asset_url) { let notificationOffset = 200; let ready = false; + let cachedHeight; // Resize parent iframe height when child height changes pymParent.onMessage('height', function(height) { - - // TODO: In local testing, this is firing nonstop. Maybe there's a bug on the inside? - // Or it's by design of pym... but that's very wasteful of CPU and DOM reflows (jank) - pymParent.el.querySelector('iframe').height = `${height }px`; + if (height !== cachedHeight) { + pymParent.el.querySelector('iframe').height = `${height }px`; + cachedHeight = height; + } }); // Helps child show notifications at the right scrollTop From a6c7fe85b91977eda145981f1786a1d5a1c3bb6d Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 2 Mar 2017 12:34:10 -0700 Subject: [PATCH 2/2] remove querySelector call --- client/coral-embed/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-embed/src/index.js b/client/coral-embed/src/index.js index d3a6a4ee5..8d8855aa7 100644 --- a/client/coral-embed/src/index.js +++ b/client/coral-embed/src/index.js @@ -36,7 +36,7 @@ function configurePymParent(pymParent, asset_url) { // Resize parent iframe height when child height changes pymParent.onMessage('height', function(height) { if (height !== cachedHeight) { - pymParent.el.querySelector('iframe').height = `${height }px`; + pymParent.el.firstChild.style.height = `${height}px`; cachedHeight = height; } });