Fancybox定位在Facebook Canvas iFrame内 [英] Fancybox Positioning Inside Facebook Canvas iFrame

查看:77
本文介绍了Fancybox定位在Facebook Canvas iFrame内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定,所以我有一个iframe画布应用程序,其高度设置为可设置与Facebook的javascrip sdk调用FB.Canvas.setSize(); 和 FB.Canvas.setAutoGrow (); 。这些工作正常,因为iframe根据其内容设置为某个像素高度。

OK so I have a iframe canvas app with its height set to "Settable" with the facebook javascrip sdk calls to FB.Canvas.setSize(); and FB.Canvas.setAutoGrow();. These are working perfectly, as the iframe gets set to a certain pixel height based on its content.

问题是当我打电话给Fancybox时,它会自己定位基于这个高度。我知道这是它应该做的,因为fancybox jQuery返回视口:

The problem is that when I make a call to Fancybox, it positions itself based on this height. I know that's exactly what its supposed to do as the fancybox jQuery returns the viewport by:

(最新版本的 jquery.fancybox-1.3.4第673行.js

_get_viewport = function() {
return [
    $(window).width() - (currentOpts.margin * 2),
    $(window).height() - (currentOpts.margin * 2),
    $(document).scrollTop() + currentOpts.margin
];
},

但是问题是iframe会让很多观众成为比他们的浏览器窗口长。所以,Fancybox在iframe中居中,最终只能部分被大多数观众看到。 (即iframe的高度是1058px,用户浏览器只有650px)。

But the problem is the iframe will, for a lot of viewers, be longer than their browser window. So the Fancybox centers itself in the iframe and ends up only partly visible to the majority of viewers. (i.e. iframe height is 1058px and users browser is say only 650px).

有没有办法让fancybox只是计算物理浏览器的高度?或者我需要更改我的Facebook画布应用程序中的某些设置以使其正常工作?

Is there a way to have fancybox just calculate the physical browser height? Or do I need to change some settings in my Facebook canvas app to make it work?

我喜欢Facebook上唯一的滚动条(父级,如果你将会)

I like how the only scrollbar is the one on Facebook (the parent, if you will).

所有建议都非常赞赏!

推荐答案

2尝试:

find:

_start: function(index) {

并替换为:

_start: function(index) {
    if ((window.parent != window) && FB && FB.Canvas) {
        FB.Canvas.getPageInfo(
            function(info) {
                window.canvasInfo = info;
                F._start_orig(index);
            }
        );
    } else   {
        F._start_orig(index);
    }
},

_start_orig: function (index) {

然后在函数 getViewport 中替换 return rez;

if (window.canvasInfo) {
    rez.h = window.canvasInfo.clientHeight;
    rez.x = window.canvasInfo.scrollLeft;
    rez.y = window.canvasInfo.scrollTop - window.canvasInfo.offsetTop;
}

return rez;

最后在 _getPosition 中替换行:

} else if (!current.locked) {

with:

} else if (!current.locked || window.canvasInfo) {

这篇关于Fancybox定位在Facebook Canvas iFrame内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆