2012-09-11 53 views
1

你好,我试图创建图像库的循环jQuery的插件http://leandrovieira.com/projects/jquery/lightbox/。 (当到达最后一个图像显示下一步按钮的第一影像,或当它首先显示的图像,为最后的图像显示上一个按钮)到目前为止,我还发现,我需要改变这些行:让循环jQuery的灯箱

 // Show the prev button, if not the first image in set 
     if (settings.activeImage != 0) { 
      if (settings.fixedNavigation) { 
       $('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' }) 
        .unbind() 
        .bind('click',function() { 
         settings.activeImage = settings.activeImage - 1; 
         _set_image_to_view(); 
         return false; 
        }); 
      } else { 
       // Show the images button for Next buttons 
       $('#lightbox-nav-btnPrev').unbind().hover(function() { 
        $(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' }); 
       },function() { 
        $(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' }); 
       }).show().bind('click',function() { 
        settings.activeImage = settings.activeImage - 1; 
        _set_image_to_view(); 
        return false; 
       }); 
      } 
     } 

     // Show the next button, if not the last image in set 
     if (settings.activeImage != (settings.imageArray.length -1)) { 
      if (settings.fixedNavigation) { 
       $('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' }) 
        .unbind() 
        .bind('click',function() { 
         settings.activeImage = settings.activeImage + 1; 
         _set_image_to_view(); 
         return false; 
        }); 
      } else { 
       // Show the images button for Next buttons 
       $('#lightbox-nav-btnNext').unbind().hover(function() { 
        $(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' }); 
       },function() { 
        $(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' }); 
       }).show().bind('click',function() { 
        settings.activeImage = settings.activeImage + 1; 
        _set_image_to_view(); 
        return false; 
       }); 
      } 
     } 

我在jquery中的知识是基本的,所以也许有人可以帮忙?

回答

0

我不确定灯箱是否支持循环。顺便说一下,你可以使用两种方法做同样的事情。

方法1:使用Fancy Box Plugin

在这个也是你的形象将在弹出的打开,它也支持周期,你所愿。它是高度可定制的。

方法2:使用Jquery Cycle Plugin随着lightbox 这个插件支持循环功能。

我会更喜欢方法1这样的实现,但如果lightbox是强制性的你使用,你可以去方法2,而不是写你自己的代码,它可能包含错误。

谢谢