我想调整整个galleria div的大小,并调整使用galleria脚本动态生成的所有图像的大小。
到目前为止,我已经
$(window).resize(function() {
var h = $(window).height();
var galleriaHeight = h-54;
var w = $(".content").width();
var galleriaWidth = w-18;
$("#galleria").height(galleriaHeight);
$("#galleria").width(w);
$(".galleria-stage").height(galleriaHeight);
$(".galleria-stage").width(galleriaWidth);
$(".galleria-images .galleria-image img").css({"max-height":"auto"});
$(".galleria-images .galleria-image img").css({"max-width":galleriaWidth-36});
$(".galleria-stage").height(galleriaHeight);
$(".galleria-stage").width(galleriaWidth);
$(".galleria-container").width(w);
$(".galleria-container").height(galleriaHeight);
$(".caption").width(w);
$(".counter-nav").width(w);
var sidebarHeight =h-54;
var contentHeight =h-36;
$(".sidebar1").height(sidebarHeight);
$(".content").height(contentHeight);
});但是所有的东西都是不均衡的,而且非常混乱。在查看了全屏代码之后,我还添加了
this.bind(Galleria.RESCALE, function() {
POS = this.getStageHeight() - tab.height() - 2;
thumbs.css('top', OPEN ? POS - list.outerHeight() + 2 : POS);
var img = this.getActiveImage();
if (img)
{
fixCaption(img);
}
});但那也不管用...
我想我想在调整大小后重新加载页面,但在运行中...或者调整所有元素相对于彼此的大小,或者使用Galleria调整大小脚本...
有什么想法吗?
发布于 2011-12-02 03:25:12
我知道这很古老,但我在任何地方都看不到答案。希望它能帮助下一个人。
这将在调整浏览器窗口大小时动态调整Galleria的大小。
我也遇到过类似的问题。我最终将以下函数绑定到窗口调整大小事件。我使用了resize事件from this post的逻辑
首先,设置resize函数:
function ResizeGallery() {
gWidth = $(window).width();
gHeight = $(window).height();
gWidth = gWidth - ((gWidth > 200) ? 100 : 0);
gHeight = gHeight - ((gHeight > 100) ? 50 : 0);
$("#gallerycontainer").width(gWidth);
$("#gallery").width(gWidth);
$("#gallery").height(gHeight);
Galleria.loadTheme('js/galleria/themes/classic/galleria.classic.js', { show: curIdx });
}然后将其绑定到窗口调整大小事件:
var TO = false;
$(window).resize(function () {
if (TO !== false)
clearTimeout(TO);
TO = setTimeout(ResizeGallery, 200); //200 is time in miliseconds
});这实际上是通过重新加载默认主题来重新初始化。在本例中,我使用第二个参数来指定要显示的图像-否则将显示第一个图像。请注意,这可能会导致Galleria的另一个实例。我相信这是个bug,还有posted on their forums。您可以按如下方式移除较旧的实例:
var gcount = Galleria.get().length;
if (gcount > 1) {
Galleria.get().splice(0, gcount - 1);
}在loadTheme方法之后运行它。使用settimeout来延迟,因为loadTheme需要一些时间才能完成。我使用200ms。很难看,但我需要Galleria中的一些功能。希望这能有所帮助。
https://stackoverflow.com/questions/5142742
复制相似问题