gpt4 book ai didi

jquery - 具有缩放以适合容器的砌体网格布局

转载 作者:太空宇宙 更新时间:2023-11-04 13:36:48 26 4
gpt4 key购买 nike

所以我正在尝试做这样的事情:http://prothemeus.com/demo/litho/

我遇到过: http://masonry.desandro.com/ , http://isotope.metafizzy.co/http://packery.metafizzy.co/它们都非常相似,但没有一个像顶部的网站那样提供缩放功能。我将如何使用这些插件之一创建类似的东西,或者有人知道提供默认缩放以适应容器的选项的插件吗?

就演示而言,我能够发现同位素处理布局,但我无法找到执行实际缩放的代码。

如有任何帮助,我们将不胜感激。

最佳答案

我忽略了所有插件,只忽略了我缩小的 smartresize,因为它在我找到它的任何地方都解压缩了。不确定它是来自 Paul Irish 还是其他人,无论哪种方式,这里都是它的 jsfiddle。 http://jsfiddle.net/matthewabrman/6R2DU/

//smartresize
(function(e,t){var n=function(e,t,n){var r;return function(){function u(){if(!n)e.apply(s,o);r=null}var s=this,o=arguments;if(r)clearTimeout(r);else if(n)e.apply(s,o);r=setTimeout(u,t||100)}};jQuery.fn[t]=function(e){return e?this.bind("resize",n(e)):this.trigger(t)}})(jQuery,"smartresize")

function redraw_UI() {
var content_width = $('.content').width()+20;
images_per_row = Math.floor(content_width / 240);
var width = Math.round(content_width / images_per_row);
var height = Math.round(width/3*2);
$('.content .item').each(function(id){
var x = Math.round((id % images_per_row) * width);
var y = Math.floor(id/images_per_row) * height + Math.floor(id/images_per_row) * 20;
if (navigator.appName.indexOf("Internet Explorer")!=-1){
$(this).animate({width: width-20+'px', height: height+'px', left: x, top: y},600);
} else {
$(this).css({'width': width-20+'px', 'height': height+'px', 'left': x, 'top': y });
}
});

if (images_per_row == 1) {
closeImagePreview();
}
}

$(window).smartresize(redraw_UI);
$(window).ready(redraw_UI);

关于jquery - 具有缩放以适合容器的砌体网格布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22995853/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com