Home › Forums › JavaScript › Nivo Slider Help
- This topic is empty.
-
AuthorPosts
-
May 1, 2013 at 11:56 am #44485
autiger811
ParticipantI have inserted a Nivo Slider into a site and the client really want the slide transition to face instead of being set on random. No matter what I’ve tried it just won’t work. Here is my code. Can anyone please help?
/* The Nivo Slider styles */.nivoSlider {
position:relative;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
}
/* 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:60;
display:none;
}/* The slices in the Slider */
.nivo-slice {
display:block;
position:absolute;
z-index:50;
height:100%;
}
/* Caption styles */
.nivo-caption {
position:absolute;
left:0px;
bottom:0px;
background:#000;
color:#fff;
opacity:0.8; /* Overridden by captionOpacity setting */
width:100%;
z-index:89;
}
.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:99;
cursor:pointer;
}
.nivo-prevNav {
left:0px;
}
.nivo-nextNav {
right:0px;
}
/* Control nav styles (e.g. 1,2,3…) */
.nivo-controlNav a {
position:relative;
z-index:99;
cursor:pointer;
}
.nivo-controlNav a.active {
font-weight:bold;
}.color2 {
color: #30ca11;May 1, 2013 at 12:22 pm #133745slicata
ParticipantI’ve never used Nivo Slider, but with most sliders the transitions are usually set in the javascript, not the css.
edit: I just took a closer look and it looks like you change the effect in the call for the slider. Here’s a clip from their demo page. Since you are not looking for all the effects just swap out “random” for the one you want and omit the settings that don’t apply.
May 1, 2013 at 1:04 pm #133746autiger811
ParticipantThanks :-) But I’m still confused :-(
Here is here the some of the java script:
(function(b){var a=function(j,q){var g=b.extend({},b.fn.nivoSlider.defaults,q);var m={currentSlide:0,currentImage:””,totalSlides:0,randAnim:””,running:false,paused:false,stop:false};var d=b(j);d.data(“nivo:vars”,m);d.css(“position”,”relative”);d.addClass(“nivoSlider”);var e=d.children();e.each(function(){var t=b(this);var s=””;if(!t.is(“img”)){if(t.is(“a”)){t.addClass(“nivo-imageLink”);s=t}t=t.find(“img:first”)}var r=t.width();if(r==0){r=t.attr(“width”)}var i=t.height();if(i==0){i=t.attr(“height”)}if(r>d.width()){d.width(r)}if(i>d.height()){d.height(i)}if(s!=””){s.css(“display”,”none”)}t.css(“display”,”none”);m.totalSlides++});if(g.startSlide>0){if(g.startSlide>=m.totalSlides){g.startSlide=m.totalSlides-1}m.currentSlide=g.startSlide}if(b(e[m.currentSlide]).is(“img”)){m.currentImage=b(e[m.currentSlide])}else{m.currentImage=b(e[m.currentSlide]).find(“img:first”)}if(b(e[m.currentSlide]).is(“a”)){b(e[m.currentSlide]).css(“display”,”block”)}d.css(“background”,”url(“+m.currentImage.attr(“src”)+”) no-repeat”);for(var k=0;k‘).css({left:(o*k)+”px”,width:(d.width()-(o*k))+”px”}))}else{d.append(b(‘
‘).css({left:(o*k)+”px”,width:o+”px”}))}}d.append(b(‘
‘).css({display:”none”,opacity:g.captionOpacity}));if(m.currentImage.attr(“title”)!=””){var n=m.currentImage.attr(“title”);if(n.substr(0,1)==”#”){n=b(n).html()}b(“.nivo-caption p”,d).html(n);b(“.nivo-caption”,d).fadeIn(g.animSpeed)}var c=0;if(!g.manualAdvance&&e.length>1){c=setInterval(function(){p(d,e,g,false)},g.pauseTime)}if(g.directionNav){d.append(‘
‘);if(g.directionNavHide){b(“.nivo-directionNav”,d).hide();d.hover(function(){b(“.nivo-directionNav”,d).show()},function(){b(“.nivo-directionNav”,d).hide()})}b(“a.nivo-prevNav”,d).live(“click”,function(){if(m.running){return false}clearInterval(c);c=””;m.currentSlide-=2;p(d,e,g,”prev”)});b(“a.nivo-nextNav”,d).live(“click”,function(){if(m.running){return false}clearInterval(c);c=””;p(d,e,g,”next”)})}if(g.controlNav){var l=b(‘
‘);d.append(l);for(var k=0;k
‘)}else{l.append(‘
‘)}}else{l.append(‘‘+(k+1)+”“)}}b(“.nivo-controlNav a:eq(“+m.currentSlide+”)”,d).addClass(“active”);b(“.nivo-controlNav a”,d).live(“click”,function(){if(m.running){return false}if(b(this).hasClass(“active”)){return false}clearInterval(c);c=””;d.css(“background”,”url(“+m.currentImage.attr(“src”)+”) no-repeat”);m.currentSlide=b(this).attr(“rel”)-1;p(d,e,g,”control”)})}if(g.keyboardNav){b(window).keypress(function(i){if(i.keyCode==”37″){if(m.running){return false}clearInterval(c);c=””;m.currentSlide-=2;p(d,e,g,”prev”)}if(i.keyCode==”39″){if(m.running){return false}clearInterval(c);c=””;p(d,e,g,”next”)}})}if(g.pauseOnHover){d.hover(function(){m.paused=true;clearInterval(c);c=””},function(){m.paused=false;if(c==””&&!g.manualAdvance){c=setInterval(function(){p(d,e,g,false)},g.pauseTime)}})}d.bind(“nivo:animFinished”,function(){m.running=false;b(e).each(function(){if(b(this).is(“a”)){b(this).css(“display”,”none”)}});if(b(e[m.currentSlide]).is(“a”)){b(e[m.currentSlide]).css(“display”,”block”)}if(c==””&&!m.paused&&!g.manualAdvance){c=setInterval(function(){p(d,e,g,false)},g.pauseTime)}g.afterChange.call(this)});var p=function(r,s,u,x){var y=r.data(“nivo:vars”);if(y&&(y.currentSlide==y.totalSlides-1)){u.lastSlide.call(this)}if((!y||y.stop)&&!x){return false}u.beforeChange.call(this);if(!x){r.css(“background”,”url(“+y.currentImage.attr(“src”)+”) no-repeat”)}else{if(x==”prev”){r.css(“background”,”url(“+y.currentImage.attr(“src”)+”) no-repeat”)}if(x==”next”){r.css(“background”,”url(“+y.currentImage.attr(“src”)+”) no-repeat”)}}y.currentSlide++;if(y.currentSlide==y.totalSlides){y.currentSlide=0;u.slideshowEnd.call(this)}if(y.currentSlide<0){y.currentSlide=(y.totalSlides-1)}if(b(s[y.currentSlide]).is("img")){y.currentImage=b(s[y.currentSlide])}else{y.currentImage=b(s[y.currentSlide]).find("img:first")}if(u.controlNav){b(".nivo-controlNav a",r).removeClass("active");b(".nivo-controlNav a:eq("+y.currentSlide+")",r).addClass("active")}if(y.currentImage.attr("title")!=""){var z=y.currentImage.attr("title");if(z.substr(0,1)=="#"){z=b(z).html()}if(b(".nivo-caption",r).css("display")=="block"){b(".nivo-caption p",r).fadeOut(u.animSpeed,function(){b(this).html(z);b(this).fadeIn(u.animSpeed)})}else{b(".nivo-caption p",r).html(z)}b(".nivo-caption",r).fadeIn(u.animSpeed)}else{b(".nivo-caption",r).fadeOut(u.animSpeed)}var w=0;b(".nivo-slice",r).each(function(){var i=Math.round(r.width()/u.slices);b(this).css({height:"0px",opacity:"0",background:"url("+y.currentImage.attr("src")+") no-repeat -"+((i+(w*i))-i)+"px 0%"});w++});if(u.effect=="random"){var
If you scroll down to the bottom of the documentation it gives a pretty good description of exactly what you’re looking for.
Basically something like the following. wherever you are calling the slider (presumably your index.html file) just replace what you have. If after the fact you want to use additional things like timing changes etc. put those after the effect.
- The forum ‘JavaScript’ is closed to new topics and replies.