简体   繁体   English

如何提供“The Wall”moo工具插件JSON数据?

[英]How to feed to “The Wall” moo tools plugin JSON data?

I fount this great plugin called "The Wall" but sadly neither the docs nor the examples show how to feed to it JSON objects. 我设想了这个名为“The Wall”的插件,但遗憾的是,文档和示例都没有显示如何向它提供JSON对象。

Say we have JSON array like: 假设我们有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"
 }
]

(It can and should be bigger) but I hope you get the point. (它可以而且应该更大)但我希望你明白这一点。 How do I make "The Wall" create a wall of images out of such JSON? 如何使“The Wall”用这样的JSON创建一个图像墙?

Some thing like: 就像是:

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM