1 Replies - 568 Views - Last Post: 05 December 2014 - 06:07 AM

#1 cerberus478   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-December 14

Slider not showing image

Posted 05 December 2014 - 04:03 AM

Hi,

I created a slider that half way works. If I click on the left arrow then the images rotates nicely, but when I click on the right arrow that is where the problem comes in. When I click on it, it rotates to the second image but after that it goes wrong. I've no idea as to why that is happening. I included a jsfiddle so that you can see what I'm talking about.

Here is the js
$(".nav_arrows").click(function(){

      $direction1 = ($(this).hasClass("left-arrow") ? "left" : "right");

      var activeBanner1 = 100;
  




      if($direction1 == "right"){

   $(".inactive_banner").css("left","100%").show();

      activeBanner1 = -100;

      if($(".active_banner").next().length < 1){

      $(".banner_wrapper").eq(0).animate({"left":0+"%","opacity":1}, 500,function(){
     $(this).addClass("active_banner").removeClass("inactive_banner");
    });
   }else{

      $(".active_banner").next().animate({"left":0+"%","opacity":1}, 500,function(){
     $(this).addClass("active_banner").removeClass("inactive_banner");
    });
   }






      }else{ //left

      $(".inactive_banner").css("left","-100%").show().fadeTo(250, 0);

      if($(".active_banner").prev().length < 1){

      $(".banner_wrapper").eq($(".banner_wrapper").length-1).animate({"left":0+"%","opacity":1}, 500,function(){
     $(this).addClass("active_banner").removeClass("inactive_banner");
    });
   }else{

      $(".active_banner").prev().animate({"left":0+"%","opacity":1}, 500,function(){
     $(this).addClass("active_banner").removeClass("inactive_banner");
    });
   }
  }
  

      $(".active_banner").animate({"left":activeBanner1+"%","opacity":0}, 500,function(){
   $(this).addClass("inactive_banner").removeClass("active_banner");
  });

  
 });




Here is a jsfiddle: JSFIDDLE

Is This A Good Question/Topic? 0
  • +

Replies To: Slider not showing image

#2 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Slider not showing image

Posted 05 December 2014 - 06:07 AM

I recommend that you first use more than two images. A slider with just two images is pretty pointless. More importantly, once you've got it working with two images, you pretty-much have to start over to get it working with three and more.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1