我发现了这个很棒的插件,名为 "The Wall"但遗憾的是,文档和 examples 都没有展示如何向其提供 JSON 对象。
假设我们有 JSON 数组,例如:
[
{
href : "/my/photo/image1.jpg",
title : "Me and Sara"
},
{
href : "/my/photo/image2.jpg",
title : "Me and Sara on a trip"
},
{
href : "/my/photo/image3.jpg",
title : "Me and Sara on a vacation"
}
]
(它可以而且应该更大)但我希望你明白这一点。如何让“The Wall”使用此类 JSON 创建图像墙?
最佳答案
像这样的事情:
var images = [
{
href : "/my/photo/image1.jpg",
title : "Me and Sara"
},
{
href : "/my/photo/image2.jpg",
title : "Me and Sara on a trip"
},
{
href : "/my/photo/image3.jpg",
title : "Me and Sara on a vacation"
}
];
var counterFluid = 1;
var maxLength = images.length;
var wallFluid = new Wall("wall", {
"draggable":true,
"inertia":true,
"width":150,
"height":150,
"rangex":[-100,100],
"rangey":[-100,100],
callOnUpdate: function(items){
items.each(function(e, i){
var a = new Element("img[src=" + images[(counterFluid -1)].href + "]");
a.inject(e.node).fade("hide").fade("in");
counterFluid++;
// Reset counter
if( counterFluid > maxLength ) counterFluid = 1;
})
}
});
// Init Fluid Wall
wallFluid.initWall();
关于javascript - 如何向 "The Wall"moo 工具插件 JSON 数据提供数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8201406/