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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/iframeResizer.contentWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

},
getId: function getIdF(){
return myID;
Expand Down