同一页面上的多个画廊 - 推进画廊

时间:2012-08-16 07:20:00

标签: javascript jquery html

我正在使用Featured Box Slider在我的网站上创建一些画廊,但在同一页面上同时运行两个画廊时遇到了问题。

我在图库上设置了一个简单的上一页和下一页按钮。但是,当我点击下一个或上一个时,它将只运行一个图库而不是为各自的图库操作。

如何解决此问题?

以下是代码:

JS

//Gallery 1 

jQuery(document).ready(function($j) {
gallery = $j("#transformed-aviation-gallery").featuredbox({
        width: 940,
        height: 400,
        slidesAnimation: "slide-left",
        startPositionOffsetX: 0,
        startPositionOffsetY: 0,
        slidesSpeed: "slow",
        hParts: 1,
        vParts: 6,
        blocksWaitInterval: 50,
        descriptionAnimation: "fade",
        descriptionSpeed: "slow",
        rotateInterval: 0,
        slidesReverseAnimation: false,
        slidesPattern: "random",
        previous: ".next",
        useFadeIn: true,
        pauseOnMouseHover: true
        });            
});

//Gallery 2
jQuery(document).ready(function($j) {
gallery = $j("#changed-aviation-gallery").featuredbox({
        width: 940,
        height: 400,
        slidesAnimation: "slide-left",
        startPositionOffsetX: 0,
        startPositionOffsetY: 0,
        slidesSpeed: "slow",
        hParts: 1,
        vParts: 6,
        blocksWaitInterval: 50,
        descriptionAnimation: "fade",
        descriptionSpeed: "slow",
        rotateInterval: 0,
        slidesReverseAnimation: false,
        slidesPattern: "random",
        previous: ".next",
        useFadeIn: true,
        pauseOnMouseHover: true
        });            
});

HTML

<div id="transformed-aviation">
  <div class="box-wrap">
   <div class="border">
    <div class="featuredbox-wrapper" id="transformed-aviation-gallery">
      <!-- Gallery Images --> 
</div>
</div>
<div  class="small img-center"> 
<a href="javascript: gallery.prev();">Previous</a>
 | 
<a href="#" id="back1" class="back">Back</a>
 | 
<a href="javascript: gallery.next();">Next</a>
</div>
</div>

<div id="changed-aviation">
  <div class="box-wrap">
   <div class="border">
    <div class="featuredbox-wrapper" id="changed-aviation-galleryy">
      <!-- Gallery Images --> 
</div>
</div>
<div  class="small img-center"> 
<a href="javascript: gallery.prev();">Previous</a>
 | 
<a href="#" id="back2" class="back">Back</a>
 | 
<a href="javascript: gallery.next();">Next</a>
</div>
</div>

我认为我需要确定上一个或下一个应该控制哪个画廊,但我该怎么做?

注意:最后一个或第二个图库是可以向前或向后移动的图库。单击下一个或上一个时,第一个库不执行任何操作。

请提供示例。

谢谢!

更新

我试图在网站上添加一个iframe,看看我是否可以让画廊玩得很好,这完全打破了画廊。

1 个答案:

答案 0 :(得分:0)

我必须更改图库代码:

//Gallery 1 

jQuery(document).ready(function($j) {
gallery1 = $j("#transformed-aviation-gallery").featuredbox({ //I added a 1 to gallery
        //gallery code
        });            
});

//Gallery 2
jQuery(document).ready(function($j) {
gallery2 = $j("#changed-aviation-gallery").featuredbox({ //I added a 2 to gallery
        //gallery code
        });            
});

然后我必须更改链接以与正确的图库相关联:

<!-- For Gallery 1 --> 
<div class="small img-center">
<a href="javascript: gallery1.prev();">Previous</a>
| 
<a href="javascript: gallery1.next();">Next</a>


<!-- For Gallery 2 --> 
<div class="small img-center">
<a href="javascript: gallery2.prev();">Previous</a>
| 
<a href="javascript: gallery2.next();">Next</a>