调整画廊大小的脚本
我想要调整整个 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调整脚本大小...
有什么想法吗?
I'm wanting to resize the entire galleria div and resize all the images dynamically generated using the galleria script.
so far I have
$(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);
});
But everything is scaling unevenly and very messed up. Having looked at the fullscreen code, I have also added
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);
}
});
but that's not working either...
I suppose I want to reload the page after i resize but on the fly... or resize all elements relative to each other, or use the Galleria resize script ...
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这已经很旧了,但我在任何地方都看不到答案。希望它可以帮助下一个人。
当浏览器窗口大小调整时,这将动态调整 Galleria 的大小。
我遇到了类似的问题。我最终将以下函数绑定到窗口调整大小事件。我使用了调整大小事件的逻辑
来自这篇文章
首先,设置调整大小功能:
然后将其绑定到窗口调整大小事件:
这实际上将通过重新加载默认主题来重新初始化。在此示例中,我使用第二个参数来指定要显示的图像 - 否则它将显示第一个图像。
请注意,这可能会导致另一个 Galleria 实例。我认为这是一个错误,并发布在他们的论坛上。您可以按如下方式删除旧实例:
在 loadTheme 方法之后运行它。使用settimeout来延迟它,因为loadTheme需要一些时间才能完成。我用的是200ms。丑陋,但我需要 Galleria 的一些功能。希望这有帮助。
I know this is old, but I don't see an answer anywhere. Hopefully it can help the next guy.
This will dynamically resize Galleria when the browser window is resized.
I ran into similar issues. I ended up binding the following function to the window resize event. I used the logic for the resize event
from this post
First, set up the resize function:
Then bind it to the window resize event:
This will essentially re-initialize by reloading the default theme. In this example, I am using the second parameter to specify which image to show- otherwise it will display the first image.
Be aware that this may cause another instance of Galleria. I believe this to be a bug, and posted on their forums. You can remove the older instances as follows:
Run it after the loadTheme method. Use settimeout to delay it, because loadTheme takes some time to complete. I use 200ms. Ugly, but I need some of the features in Galleria. Hope this helps.