FB.Canvas.setAutoGrow

From Facebook Developer Wiki (FbDevWiki.com)
(Redirected from FB.Canvas.setAutoResize)
Jump to: navigation, search

(official docs) (was FB.Canvas.setAutoResize)

Starts or stops a timer which resizes your iframe every few milliseconds.

Examples

This function is useful if you know your content will change size, but you don't know when. There will be a slight delay, so if you know when your content changes size, you should call setSize yourself (and save your user's CPU cycles).

window.fbAsyncInit = function() {
  FB.Canvas.setAutoGrow();
}

If you ever need to stop the timer, just pass false.

FB.Canvas.setAutoGrow(false);

If you want the timer to run at a different interval, you can do that too.

FB.Canvas.setAutoGrow(91); // 91ms


Parameters

Note: If there is only 1 parameter and it is a number, it is assumed to be the interval.

Name Type Description Default
onOrOff Boolean true = timer on, false = timer off true
interval Integer How often to resize (in ms) 100


Bugs

I noticed some complaints about the auto resizing not working in some browsers and found the following hack in some comments on the official docs:

This fix that someone wrote seems to do the trick otherwise (it's a bit of a hack though):
FB.Array.forEach([200, 600, 1000, 2000, 5000, 10000], function(delay) {
setTimeout(function() { FB.Arbiter.inform("setSize", FB.Canvas._computeContentSize()) }, delay)
});

You can specify at what milliseconds the iframe should try to resize..

Personal tools
Namespaces
Variants
Actions
Navigation
Graph API
FQL
Toolbox