我设想了这个名为"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创建一个图像墙?
答案 0 :(得分:2)
有些事情:
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();