From 621aa8846d3dc02243bafdf016675032f32edf58 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sun, 11 Jan 2015 14:14:53 -0500 Subject: [PATCH 1/2] Listen for transitionend events In Safari, I've observed situations along the lines of: * Changing the DOM class of an element initiates a height transition * When the attribute change is observed, Safari still reports the body height as its pre-transition value * Once `transitionend` fires, the reported height is correct I do not observe this behavior on Chrome or Firefox, but the change herein should not hurt in those browsers either. --- src/iframeResizer.contentWindow.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/iframeResizer.contentWindow.js b/src/iframeResizer.contentWindow.js index 6d13cc5e8..10649f2c7 100644 --- a/src/iframeResizer.contentWindow.js +++ b/src/iframeResizer.contentWindow.js @@ -158,6 +158,7 @@ if ( true === autoResize ) { initWindowResizeListener(); initWindowClickListener(); + initTransitionListener(); setupMutationObserver(); } else { @@ -243,6 +244,18 @@ }); } + function initTransitionListener(){ + function onTransitionEnd(e){ + if (e.propertyName === 'height' || e.propertyName === 'width') { + sendSize('transitionend','Transition end'); + } + } + addEventListener(window,'transitionend', onTransitionEnd) + addEventListener(window,'webkitTransitionEnd', onTransitionEnd) + addEventListener(window,'oTransitionEnd',onTransitionEnd) + addEventListener(window,'otransitionend',onTransitionEnd) + } + function setupMutationObserver(){ var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; From 6f3cf6c488d18590066f4b75c8f92ab956bf6eb2 Mon Sep 17 00:00:00 2001 From: Mat Brown Date: Sun, 11 Jan 2015 15:05:22 -0500 Subject: [PATCH 2/2] Semicolons --- src/iframeResizer.contentWindow.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/iframeResizer.contentWindow.js b/src/iframeResizer.contentWindow.js index 10649f2c7..1fff4b2a1 100644 --- a/src/iframeResizer.contentWindow.js +++ b/src/iframeResizer.contentWindow.js @@ -250,10 +250,10 @@ sendSize('transitionend','Transition end'); } } - addEventListener(window,'transitionend', onTransitionEnd) - addEventListener(window,'webkitTransitionEnd', onTransitionEnd) - addEventListener(window,'oTransitionEnd',onTransitionEnd) - addEventListener(window,'otransitionend',onTransitionEnd) + addEventListener(window,'transitionend', onTransitionEnd); + addEventListener(window,'webkitTransitionEnd', onTransitionEnd); + addEventListener(window,'oTransitionEnd',onTransitionEnd); + addEventListener(window,'otransitionend',onTransitionEnd); } function setupMutationObserver(){