简体   繁体   English

Facebook JS SDK滚动

[英]Facebook JS SDK Scrolling

I have some simple piece of codes which scroll the page to top with animation by clicking on every link containing the class of "top" and some other codes which I use them to scrol down to a specific div id. 我有一些简单的代码,通过点击包含“top”类的每个链接以及我用它们向下滚动到特定div id的其他代码,将页面滚动到顶部。

But When I remove vertical scrolbar in facebook app pages by adding FB.Canvas.setAutoGrow(); 但是当我通过添加FB.Canvas.setAutoGrow()删除Facebook应用页面中的垂直滚动条时; and FB.Canvas.setSize(); FB.Canvas.setSize(); that piece of code does not work any more in the facebook app page and I can not scroll to top and down. 这段代码在facebook应用程序页面中不再起作用,我无法向上和向下滚动。 I searched and it seems we should use FB.Canvas.scrollTo from Facebook JS SDK instead. 我搜索了,似乎我们应该使用来自Facebook JS SDK的FB.Canvas.scrollTo

By the way as much as I try to do so it seems I can't do that. 顺便说一句,尽管我尝试这样做,但我似乎无法做到这一点。 If anybody can guide me in this regard I'll be so thankful. 如果有人能在这方面指导我,我会非常感激。

In the setting, it should be set to fluid. 在设置中,它应设置为流体。 also just using setAutoGrow() should be enough. 也只是使用setAutoGrow()就足够了。

Notice that FB.Canvas.scrollTo and FB.Canvas.setSize only work when you have the screen height as fixed so you can manage the canvas size and locate the user where you want. 请注意,FB.Canvas.scrollTo和FB.Canvas.setSize仅在屏幕高度固定时才起作用,因此您可以管理画布大小并找到所需的用户。 In fact FB.Canvas.scrollTo doesn't work in Fluid mode! 实际上FB.Canvas.scrollTo在流体模式下不起作用! btw, if your planning to use the fixed height, it's useful to manage to screen height change in the following way: 顺便说一句,如果您计划使用固定高度,以下列方式管理屏幕高度变化很有用:

$(window).resize(function() {

    scrHeight = $(window).height();

    // now you can use FB.Canvas.scrollTo and FB.Canvas.setSize 
    // here to satisfy your purposes  
});

In your FB app settings you have: 在您的FB应用程序设置中,您有:

Canvas Width:Fluid
Fixed (760px)
Canvas Height: Fluid
Fixed at X px

check if you selected fluid height 检查您是否选择了液体高度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM