javascriptjqueryfancyboxfancybox-2nivo-slider

Using Fancybox and Nivo Slider


I'm using Nivo Slider on my webpage, what i'm trying to do is make the current slide image pop out in a fancybox lightbox.

My current jquery is.

<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider({
effect: 'slideInLeft',               // Specify sets like: 'fold,fade,sliceDown'
slices: 15,                     // For slice animations
boxCols: 8,                     // For box animations
boxRows: 4,                     // For box animations
animSpeed: 500,                 // Slide transition speed
pauseTime: 3000,                // How long each slide will show
startSlide: 0,                  // Set starting Slide (0 index)
directionNav: true,             // Next & Prev navigation
controlNav: true,               // 1,2,3... navigation
controlNavThumbs: false,        // Use thumbnails for Control Nav
pauseOnHover: true,             // Stop animation while hovering
manualAdvance: false,           // Force manual transitions
prevText: 'Prev',               // Prev directionNav text
nextText: 'Next',               // Next directionNav text
randomStart: false,             // Start on a random slide
beforeChange: function(){},     // Triggers before a slide transition
afterChange: function(){},      // Triggers after a slide transition
slideshowEnd: function(){},     // Triggers after all slides have been shown
lastSlide: function(){},        // Triggers when last slide is shown
afterLoad: function(){}         // Triggers when slider has loaded
});
});
</script>

and my HTML is.

<div class="colE">

<div style="height: 265px; margin-top: 25px" id="slider" class="nivoSlider">
 <img src="/images/new.jpg" alt=""/>
 <img src="/images/new1.jpg"" alt=""/>
 <img src="/images/new2.jpg"" alt=""/>
 <img src="/images/new3.jpg"" alt=""/>
</div>

</div>

CSS is mostly just the standard version I have added.

<style>
.nivoSlider {
position:relative;
width:100%;
height:auto 265px;
overflow: hidden;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
max-width: none;
display: none;
}
.nivo-main-image {
display: block !important;
position: relative !important; 
width: 100% !important;
}

/* If an image is wrapped in a link */
.nivoSlider a.nivo-imageLink {
position:absolute;
top:0px;
left:0px;
width:100%;
height:100%;
border:0;
padding:0;
margin:0;
z-index:6;
display:none;
}
/* The slices and boxes in the Slider */
.nivo-slice {
display:block;
position:absolute;
z-index:5;
height:100%;
top:0;
}
.nivo-box {
display:block;
position:absolute;
z-index:5;
overflow:hidden;
}
.nivo-box img { display:block; }

/* Caption styles */
.nivo-caption {
position:absolute;
left:0px;
bottom:0px;
background:#000;
color:#fff;
width:100%;
z-index:8;
padding: 5px 10px;
opacity: 0.8;
overflow: hidden;
display: none;
-moz-opacity: 0.8;
filter:alpha(opacity=8);
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box;    /* Firefox, other Gecko */
box-sizing: border-box;         /* Opera/IE 8+ */
}
.nivo-caption p {
padding:5px;
margin:0;
}
.nivo-caption a {
display:inline !important;
}
.nivo-html-caption {
display:none;
}
/* Direction nav styles (e.g. Next & Prev) */
.nivo-directionNav a {
position:absolute;
top:45%;
z-index:9;
cursor:pointer;
}
.nivo-prevNav {
left:0px;
}
.nivo-nextNav {
right:0px;
}
/* Control nav styles (e.g. 1,2,3...) */
.nivo-controlNav {
text-align:center;
padding: 15px 0;
}
.nivo-controlNav a {
cursor:pointer;
}
.nivo-controlNav a.active {
font-weight:bold;
}

.nivoSlider {
position:relative;
background:#fff url(images/loading.gif) no-repeat 50% 50%;
width:65%;
height:100%;
margin-bottom:10px;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
display:none;
}
.nivoSlider a {
border:0;
display:block;
}

.nivo-controlNav {
text-align: center;
padding: 0 0;
margin-left: -300px;
}
.nivo-controlNav a {
display:inline-block;
width:22px;
height:22px;
background:url(images/bullets.png) no-repeat;
text-indent:-9999px;
border:0;
margin: 0 2px;
}
.nivo-controlNav a.active {
background-position:0 -22px;
}

.nivo-directionNav a {
display:block;
width:30px;
height:30px;
background:url(images/arrows.png) no-repeat;
text-indent:-9999px;
border:0;
opacity: 0;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
.nivoSlider:hover .nivo-directionNav a { opacity: 1; }
a.nivo-nextNav {
background-position:-30px 0;
right:15px;
}
a.nivo-prevNav {
left:15px;
}

.nivo-caption {
font-family: Helvetica, Arial, sans-serif;
}
.nivo-caption a {
color:#fff;
border-bottom:1px dotted #fff;
}
.nivo-caption a:hover {
color:#fff;
}

.nivo-controlNav.nivo-thumbs-enabled {
width: 100%;
}
.nivo-controlNav.nivo-thumbs-enabled a {
width: auto;
height: auto;
background: none;
margin-bottom: 5px;
}
.nivo-controlNav.nivo-thumbs-enabled img {
display: block;
width: 120px;
height: auto;
}
</style>

Updated

Heres the JSFiddle,

It doesn't seem to work like on the website??

http://jsfiddle.net/6AqR6/

It does what its supposed to do which is slide i would just like to add the popout function on the current slide.

I hope there isn't to much code or the post is wrong if so please tell me and i shall update it.

Thanks.


Solution

  • if you change your html to the following:

    <div style="height: 265px; margin-top: 25px" id="slider" class="nivoSlider">
      <a href="/images/new.jpg" class="fancybox"><img src="/images/new.jpg" alt=""/></a>
      <a href="/images/new1.jpg" class="fancybox"><img src="/images/new1.jpg" alt=""/></a>
      <a href="/images/new2.jpg" class="fancybox"><img src="/images/new2.jpg" alt=""/></a>
      <a href="/images/new3.jpg" class="fancybox"><img src="/images/new3.jpg" alt=""/></a>
    </div>
    

    You can change the window load to:

    $(window).load(function() {
        ...previous nivo function goes here
    
        $('.nivoSlider a.fancybox').fancybox();
    });
    

    Example

    Please note you will need to play with the z-index of the fancybox to ensure it appears on top of the nivo slider