Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified close to always trigger change #171

Merged
merged 1 commit into from
Mar 17, 2015

Conversation

ReedD
Copy link
Contributor

@ReedD ReedD commented Mar 16, 2015

On line 577 isSizeChangeDetected() is called and returns false which I believe is the reason the event never propagates to the parent window. I simply modified the close event to send Infinity rather than 0.

@@ -292,7 +292,7 @@

window.parentIFrame = {
close: function closeF(){
sendSize('close','parentIFrame.close()', 0, 0);
sendSize('close','parentIFrame.close()', Infinity, Infinity);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't make a difference, as the values are ignored on the host page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidjbradshaw the problem isn't with the host page, the problem is that the host page never even receives the event because of the function I referenced here on line 577 isSizeChangeDetected().

function isSizeChangeDetected(){
    function checkTolarance(a,b){
        var retVal = Math.abs(a-b) <= tolerance;
        return !retVal;
    }

    currentHeight = (undefined !== customHeight)  ? customHeight : getHeight[heightCalcMode]();
    currentWidth  = (undefined !== customWidth )  ? customWidth  : getWidth();

    return  checkTolarance(height,currentHeight) ||
            (calculateWidth && checkTolarance(width,currentWidth));
}

Which is defined as above. When currentHeight and customHeight are both 0 checkTolarance and thus isSizeChangeDetected both return false. If no change is detected then no event is propagated/sent to the host page. My fix sets customHeight to Infinity which essentially guarantees isSizeChangeDetected will always return true when a close event is triggered.

@davidjbradshaw
Copy link
Owner

Ah got you. Good spot.

davidjbradshaw added a commit that referenced this pull request Mar 17, 2015
Modified `close` to always trigger change
@davidjbradshaw davidjbradshaw merged commit 78b9597 into davidjbradshaw:master Mar 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants