Skip to content

Instantly share code, notes, and snippets.

@cgallagher
Created March 28, 2012 09:07
Show Gist options
  • Save cgallagher/2224958 to your computer and use it in GitHub Desktop.
Save cgallagher/2224958 to your computer and use it in GitHub Desktop.
Animate scroll top within FB iFrame
function scroll_to_top() {
FB.Canvas.getPageInfo(function (pageInfo) {
var iframe_scroll_y = pageInfo.scrollTop;
var target_div_y = $('#dr_dre').position().top;
if (iframe_scroll_y > target_div_y) {
var animOptions = {
step: function () {
FB.Canvas.scrollTo(0, this.y);
},
duration: 200
};
$({ y: iframe_scroll_y }).animate({ y: target_div_y }, animOptions);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment