2012-09-11 51 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,而不是寫你自己的代碼,它可能包含錯誤。

謝謝