Nikolaos Vassos
Nikolaos Vassos

Reputation: 246

Resizing canvas for the app

we have been trying to setup the height for a canvas app without luck.

this is the code we are using

window.fbAsyncInit = function()
{
// assume we are already logged in
FB.init({appId: '<?=$fb_app_id ?>', xfbml: true, oauth : true,cookie: true});
FB.Canvas.setAutoGrow();
}
function sizeChangeCallback() {
FB.Canvas.setSize({ width: 810, height: 950);
}

We tried both without the sizechangecallback

and our settings set to Fixed and Fixed 950

Upvotes: 0

Views: 444

Answers (1)

Philip
Philip

Reputation: 5021

After you setup the fixed height parameter in your application settings,
you can call FB.Canvas.setSize to change the page height.

If your page height changes dynamically, you can run FB.Canvas.setDoneLoading
to check if Canvas is loaded and run FB.Canvas.setAutoGrow.

window.fbAsyncInit = function() {
    // assume we are already logged in
    FB.init({ appId: '<?=$fb_app_id ?>', xfbml: true, oauth: true, cookie: true });

    FB.Canvas.setSize({ width: 810, height: 950 });

    FB.Canvas.setDoneLoading( function(response) {
        console.log(response.time_delta_ms);
        FB.Canvas.setAutoGrow();
    });
}

FB Documentation: https://developers.facebook.com/docs/reference/javascript/FB.Canvas.setDoneLoading/

Upvotes: 2

Related Questions