Add arrows to carousel

1

I wanted to know if there is any way to add arrows to make it run to this type of carousel , in addition to having the touch (which already comes by default) and that runs on its own.

This is my code:

(function($, undefined) {

  $(window).on("load", function() {
    $("#carouselTicker").carouselTicker();
  })

  $("#carouselTicker1").carouselTicker({
    "direction": "next"
  });

  $("#carouselTicker1").carouselTicker({
    "direction": "next"
  });

  $(".carouselTicker-start").carouselTicker({
    "direction": "next"
  });

  var carouselTickerWidthResize = $("#carouselTicker-width-resize").carouselTicker();

  $(window).on('resize', function() {
    carouselTickerWidthResize.resizeTicker();
  });

  $("#carouselTicker-vertical").carouselTicker({
    "mode": "vertical",
    "direction": "prev"
  });

  $("#carouselTicker-vertical-with-callback").carouselTicker({
    "mode": "vertical",
    "direction": "next",
    "onCarouselTickerLoad": function() {
      console.log("callback")
    }
  });

})(jQuery);
#main-content {
  float: left;
  width: 900px;
}

#main-content img {
  max-width: 100%;
}


/* MISC */

.clearfix:after {
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
  content: '.';
}

.clearfix {
  display: inline-block;
}

* html .clearfix {
  height: 1%;
}

.clearfix {
  display: block;
}


/* #Media Queries
================================================== */


/* Smaller than standard 960 (devices and browsers) */

@media only screen and (max-width: 959px) {}


/* Tablet Portrait size to standard 960 (devices and browsers) */

@media only screen and (min-width: 768px) and (max-width: 959px) {
  #main-content {
    width: 490px;
  }
  #main-content h1:before,
  #main-content h2:before,
  #main-content h3:before,
  #main-content h4:before,
  #main-content h5:before,
  #main-content h6:before {
    padding-right: 0;
    margin-left: 0;
    content: none;
  }
}


/* All Mobile Sizes (devices and browser) */

@media only screen and (max-width: 767px) {
  #main-content h1:before,
  #main-content h2:before,
  #main-content h3:before,
  #main-content h4:before,
  #main-content h5:before,
  #main-content h6:before {
    padding-right: 0;
    margin-left: 0;
    content: none;
  }
}

.carouselTicker__list {
  margin: 10px 0;
  padding: 0;
  list-style-type: none;
  overflow: hidden;
}

.carouselTicker__item {
  margin: 0 0 0 5px;
  float: left;
  border: 4px solid red;
  width: 100px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}

.carouselTicker__loader {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: #fff url("../images/loader.gif") center center no-repeat;
}


/**
 * CSS style for vertical direction
 **/

.carouselTicker_vertical .carouselTicker__list {
  margin: 0;
}

.carouselTicker_vertical .carouselTicker__item {
  margin: 0 0 5px 0;
  border: 4px solid red;
  width: 100px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}

#carouselTicker .carouselTicker__item {
  width: auto;
  height: auto;
  line-height: normal;
}

.carouselTicker__item img {
  vertical-align: top;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://www.jqueryscript.net/demo/Carousel-Style-Content-Ticker-Plugin-with-jQuery-Carousel-Ticker/javascripts/jquery.carousel-ticker.js"></script>

<section id="main-content">
  <div id="demos">

    <div id="carouselTicker" class="carouselTicker">
      <ul class="carouselTicker__list">
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
      </ul>
    </div>



  </div>
</section>
    
asked by MarianoF 19.12.2017 в 14:49
source

1 answer

1

Good friend the library as such I think it does not have that functionality but failing that you can program it yourself for that you have to add to the item .carouselTicker__list containing all the images the left desired in case of the flecha1 (<) We remove -=200px and in the case of flecha2 (>) we add -=200 I hope you help greetings.

Detailed Explanation

  

To add a property to an element, adding it to the one that already has use += and to subtract it we use -= .

     

In this case we want an animation to add and remove px to left for that we use the function animate()

$(".carouselTicker__list").animate({"left":"-=200px"}) //quitar

$(".carouselTicker__list").animate({"left":"+=200px"}) //agregar

Functional Example

(function($, undefined) {

  $(window).on("load", function() {
    $("#carouselTicker").carouselTicker();
  })

  $("#carouselTicker1").carouselTicker({
    "direction": "next"
  });

  $("#carouselTicker1").carouselTicker({
    "direction": "next"
  });

  $(".carouselTicker-start").carouselTicker({
    "direction": "next"
  });

  var carouselTickerWidthResize = $("#carouselTicker-width-resize").carouselTicker();

  $(window).on('resize', function() {
    carouselTickerWidthResize.resizeTicker();
  });

  $("#carouselTicker-vertical").carouselTicker({
    "mode": "vertical",
    "direction": "prev"
  });

  $("#carouselTicker-vertical-with-callback").carouselTicker({
    "mode": "vertical",
    "direction": "next",
    "onCarouselTickerLoad": function() {
      console.log("callback")
    }
  });

})(jQuery);

/*Nuevas functiones para las flechas*/
  $(".flecha1").click(function(){
    $(".carouselTicker__list").animate({"left":"-=200px"})
  })
  
    $(".flecha2").click(function(){
    $(".carouselTicker__list").animate({"left":"+=200px"})
  })
#main-content {
  float: left;
  width: 900px;
}

#main-content img {
  max-width: 100%;
}


/* MISC */

.clearfix:after {
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
  content: '.';
}

.clearfix {
  display: inline-block;
}

* html .clearfix {
  height: 1%;
}

.clearfix {
  display: block;
}


/* #Media Queries
================================================== */


/* Smaller than standard 960 (devices and browsers) */

@media only screen and (max-width: 959px) {}


/* Tablet Portrait size to standard 960 (devices and browsers) */

@media only screen and (min-width: 768px) and (max-width: 959px) {
  #main-content {
    width: 490px;
  }
  #main-content h1:before,
  #main-content h2:before,
  #main-content h3:before,
  #main-content h4:before,
  #main-content h5:before,
  #main-content h6:before {
    padding-right: 0;
    margin-left: 0;
    content: none;
  }
}


/* All Mobile Sizes (devices and browser) */

@media only screen and (max-width: 767px) {
  #main-content h1:before,
  #main-content h2:before,
  #main-content h3:before,
  #main-content h4:before,
  #main-content h5:before,
  #main-content h6:before {
    padding-right: 0;
    margin-left: 0;
    content: none;
  }
}

.carouselTicker__list {
  margin: 10px 0;
  padding: 0;
  list-style-type: none;
  overflow: hidden;
}

.carouselTicker__item {
  margin: 0 0 0 5px;
  float: left;
  border: 4px solid red;
  width: 100px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}

.carouselTicker__loader {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: #fff url("../images/loader.gif") center center no-repeat;
}


/**
 * CSS style for vertical direction
 **/

.carouselTicker_vertical .carouselTicker__list {
  margin: 0;
}

.carouselTicker_vertical .carouselTicker__item {
  margin: 0 0 5px 0;
  border: 4px solid red;
  width: 100px;
  height: 60px;
  line-height: 60px;
  text-align: center;
}

#carouselTicker .carouselTicker__item {
  width: auto;
  height: auto;
  line-height: normal;
}

.carouselTicker__item img {
  vertical-align: top;
}


/*Nuevo codigo Flechas*/
*{
  padding:0;
  margin:0;
}
#main-content{
  width:100% !important;
}

.con-carrusel{
  position:relative;
  overflow:hidden;
  width:100%;
}
.flecha1 {
  position: absolute;
  top: 0px;
  left: 0px;
  height: 100%;
  width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index:100;
  background: rgb(255, 255, 255);
  color: rgb(86, 131, 191);
  border: 0px;
  outline: none;
  box-shadow: 5px 0px 10px 0px rgba(0, 0, 0, 0.1);
}
.flecha2 {
  position: absolute;
  top: 0px;
  right: 0px;
  height: 100%;
  width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index:100;
  background: rgb(255, 255, 255);
  color: rgb(86, 131, 191);
  border: 0px;
  outline: none;
  box-shadow: -5px 0px 10px 0px rgba(0, 0, 0, 0.1);
}
.flecha1,.flecha2{
  font-size: 24px;
  cursor: pointer;
  transition: all .3s ease;
}
.flecha1:hover,.flecha2:hover{
  background: rgb(86, 131, 191);
  color: rgb(255, 255, 255);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://www.jqueryscript.net/demo/Carousel-Style-Content-Ticker-Plugin-with-jQuery-Carousel-Ticker/javascripts/jquery.carousel-ticker.js"></script>

<section id="main-content">
  <div id="demos">
<div class="con-carrusel">
<button class="flecha1" type="button" name="button"><i class="fa fa-angle-left" aria-hidden="true"></i></button>
    <div id="carouselTicker" class="carouselTicker">
    
      <ul class="carouselTicker__list">
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
        <li class="carouselTicker__item">
          <a href="#"><img src="http://placehold.it/190x65" alt="banner image"></a>
        </li>
      </ul>
      
    </div>
    <button class="flecha2" type="button" name="button"><i class="fa fa-angle-right" aria-hidden="true"></i></button>
</div>


  </div>
</section>

<script src="https://use.fontawesome.com/ef8ad22161.js"></script>
    
answered by 19.12.2017 / 16:23
source