如何用图像数组打开fancybox [英] How to open fancybox with array of images

查看:103
本文介绍了如何用图像数组打开fancybox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JS中遇到了一系列图片毛病:

i have an array of images ulrs in JS:

photos= ['img1.jpg','img2.jpg',...]

我正在使用Fancybox 2.

I'm using Fancybox 2.

如何打开带有数组图像的fancybox?

How can I open fancybox with the images of the array?

$('#start_slides').fancybox({
    'openEffect'    :   'elastic',
    'closeEffect'   :   'elastic',
    'openSpeed'     :   600, 
    'closeSpeed'    :   200,
    helpers : {
        buttons : {}
    }
});

$.fancybox.open(photos,{});

但是,这仅显示了一个以URL为文本的fancybox.

But this is only showing a fancybox with the urls as text.

我的最终结果应该是一个幻想盒,像幻灯片一样显示图像.

My final result should be a fancybox with showing the images like a slideshow.

谢谢

推荐答案

找到了一个解决方案: photos数组必须采用以下格式:

Found a solution: The photos array must be in the format:

photos = [ {href : 'img1.jpg', title : 'Title'}, {href : 'img2.jpg', title : 'Title'} ]

然后它正在工作.

并且初始化可以通过以下方式正确完成:

And the initializing is done correctly by:

$('#start_slides').fancybox();

$.fancybox.open(photos,{
    'openEffect'    :   'elastic',
    'closeEffect'   :   'elastic',
    'nextEffect'    :   'fade',
    'openSpeed'     :   600, 
    'closeSpeed'    :   200,
    helpers : {
        buttons : {}
    }
});

这篇关于如何用图像数组打开fancybox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆