So I had this app on facebook and from the FB documentation I found that in order to trigger a scrolling functionality on click I first need to load the FB SDK by adding this code:
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'i put my app id here',
xfbml : true,
version : 'v2.3'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
and then I had this img with id #button1 that behaves like a button using jQuery click() method. I wanted to have the canvas scrolled to this element #button1 so I put this line of code into the click() method like this
$("#button1").click(function(){
FB.Canvas.scrollTo(0, offset);
}
Nothing happened. So I searched around and found this topic How do you animate FB.Canvas.scrollTo?
so I added the function
function scrollTo(y){
FB.Canvas.getPageInfo(function(pageInfo){
$({y: pageInfo.scrollTop}).animate(
{y: y},
{duration: 1000, step: function(offset){
FB.Canvas.scrollTo(0, offset);
}
});
});
}
and used it as
$("#button1").click(function(){
scrollTo("#button1");
}
nothing happens still. What happened ?