jQuery Slideshow with animation callback












0















I have developed a slideshow using jQuery that will pre-loade the next slide, hold the last one, and make the current slide active which adds a class with a delay.



I predict there could be unnecessary duplication within the next and previous buttons. Are there improvements that can be made to the code, and if so, what would these be?






$(document).ready(function(){

$('.slide:eq(-1)').addClass('last');
$('.slide:first').addClass('active').delay(1250).queue(function(){
$(this).addClass('show-text');
});
$('.slide:eq(1)').addClass('next');

});

// Previous Slide
function prevSlide() {

// Variables
var $prevActive = $('.slide.active');
var $prevSlide = $('.slide').eq(($prevActive.index() - 1) % $('.slide').length);
var $afterPrevSlide = $('.slide').eq(($prevActive.index() - 2) % $('.slide').length);

// Remove previous classes
$prevActive.dequeue();
$('.slide').removeClass('last active show-text next');

// Add the new classes
$prevActive.addClass('next');
$prevSlide.addClass('active').delay(1250).queue(function(){
$(this).addClass('show-text');
});
$afterPrevSlide.addClass('last');

}

// Next Slide
function nextSlide() {

// Variables
var $activeSlide = $('.slide.active');
var $nextSlide = $('.slide').eq(($activeSlide.index() + 1) % $('.slide').length);
var $slideAfterNext = $('.slide').eq(($activeSlide.index() + 2) % $('.slide').length);

// Remove the previous classes
$activeSlide.dequeue();
$('.slide').removeClass('last active show-text next');

// Add the new classes
$activeSlide.addClass('last');
$nextSlide.addClass('active').delay(1250).queue(function(){
$(this).addClass('show-text');
});
$slideAfterNext.addClass('next');

}

$('#prev').click(function(){

prevSlide();

});

$('#next').click(function(){

nextSlide();

});

body {
font-size: 16px;
font-family: 'Heebo', sans-serif;
text-transform: uppercase;
font-weight: 900;
}

/* Slides */
.slide-wrapper {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
display: flex;
overflow: hidden;
}

.slide {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
width: 70%;
left: 140%;
z-index: 0;
transition: 1.25s;
box-shadow: -10px 0px 21px -5px rgba(0,0,0,0.5);
}

.slide h2 {
display: none;
color: #fff;
text-shadow: 0px 0px 8px rgba(0,0,0,0.5);
letter-spacing: -2px;
font-size: 3rem;
}

.slide.active.show-text h2 {
display: block;
animation: reveal-text 1.5s forwards;
}

@keyframes reveal-text {
0% { opacity: 0; }
100% { opacity: 1; }
}

#slide1 {
background: linear-gradient(to right, #93EDC7, #1CD8D2);
}

#slide2 {
background: linear-gradient(to right, #4389A2, #5C258D);
}

#slide3 {
background: linear-gradient(to right, #8E54E9, #4776E6);
}

#slide4 {
background: linear-gradient(to right, #F45C43, #EB3349);
}

.slide.last {
left: 0;
z-index: 0;
}

.slide.active {
left: 0;
z-index: 1;
}

.slide.next {
left: 70%;
z-index: 2;
}

/* Buttons */
.button-wrapper {
display: flex;
z-index: 10;
width: 100%;
justify-content: space-between;
align-items: center;
}

.button {
background-color: rgba(0,0,0,0.45);
color: #ddd;
height: 40px;
border: none;
font-weight: bold;
padding: 10px 20px;
transition: 0.3s;
}

.button:hover {
cursor: pointer;
background: rgba(0,0,0,0.85);
color: #fff;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="slide-wrapper">
<div id="slide1" class="slide">
<h2>Slide One.</h2>
</div>
<div id="slide2" class="slide">
<h2>Slide Two.</h2>
</div>
<div id="slide3" class="slide">
<h2>Slide Three.</h2>
</div>
<div id="slide4" class="slide">
<h2>Slide Four.</h2>
</div>
<div class="button-wrapper">
<button id="prev" class="button">Prev.</button>
<button id="next" class="button">Next.</button>
</div>
</div>












share|improve this question





























    0















    I have developed a slideshow using jQuery that will pre-loade the next slide, hold the last one, and make the current slide active which adds a class with a delay.



    I predict there could be unnecessary duplication within the next and previous buttons. Are there improvements that can be made to the code, and if so, what would these be?






    $(document).ready(function(){

    $('.slide:eq(-1)').addClass('last');
    $('.slide:first').addClass('active').delay(1250).queue(function(){
    $(this).addClass('show-text');
    });
    $('.slide:eq(1)').addClass('next');

    });

    // Previous Slide
    function prevSlide() {

    // Variables
    var $prevActive = $('.slide.active');
    var $prevSlide = $('.slide').eq(($prevActive.index() - 1) % $('.slide').length);
    var $afterPrevSlide = $('.slide').eq(($prevActive.index() - 2) % $('.slide').length);

    // Remove previous classes
    $prevActive.dequeue();
    $('.slide').removeClass('last active show-text next');

    // Add the new classes
    $prevActive.addClass('next');
    $prevSlide.addClass('active').delay(1250).queue(function(){
    $(this).addClass('show-text');
    });
    $afterPrevSlide.addClass('last');

    }

    // Next Slide
    function nextSlide() {

    // Variables
    var $activeSlide = $('.slide.active');
    var $nextSlide = $('.slide').eq(($activeSlide.index() + 1) % $('.slide').length);
    var $slideAfterNext = $('.slide').eq(($activeSlide.index() + 2) % $('.slide').length);

    // Remove the previous classes
    $activeSlide.dequeue();
    $('.slide').removeClass('last active show-text next');

    // Add the new classes
    $activeSlide.addClass('last');
    $nextSlide.addClass('active').delay(1250).queue(function(){
    $(this).addClass('show-text');
    });
    $slideAfterNext.addClass('next');

    }

    $('#prev').click(function(){

    prevSlide();

    });

    $('#next').click(function(){

    nextSlide();

    });

    body {
    font-size: 16px;
    font-family: 'Heebo', sans-serif;
    text-transform: uppercase;
    font-weight: 900;
    }

    /* Slides */
    .slide-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    display: flex;
    overflow: hidden;
    }

    .slide {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 70%;
    left: 140%;
    z-index: 0;
    transition: 1.25s;
    box-shadow: -10px 0px 21px -5px rgba(0,0,0,0.5);
    }

    .slide h2 {
    display: none;
    color: #fff;
    text-shadow: 0px 0px 8px rgba(0,0,0,0.5);
    letter-spacing: -2px;
    font-size: 3rem;
    }

    .slide.active.show-text h2 {
    display: block;
    animation: reveal-text 1.5s forwards;
    }

    @keyframes reveal-text {
    0% { opacity: 0; }
    100% { opacity: 1; }
    }

    #slide1 {
    background: linear-gradient(to right, #93EDC7, #1CD8D2);
    }

    #slide2 {
    background: linear-gradient(to right, #4389A2, #5C258D);
    }

    #slide3 {
    background: linear-gradient(to right, #8E54E9, #4776E6);
    }

    #slide4 {
    background: linear-gradient(to right, #F45C43, #EB3349);
    }

    .slide.last {
    left: 0;
    z-index: 0;
    }

    .slide.active {
    left: 0;
    z-index: 1;
    }

    .slide.next {
    left: 70%;
    z-index: 2;
    }

    /* Buttons */
    .button-wrapper {
    display: flex;
    z-index: 10;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    }

    .button {
    background-color: rgba(0,0,0,0.45);
    color: #ddd;
    height: 40px;
    border: none;
    font-weight: bold;
    padding: 10px 20px;
    transition: 0.3s;
    }

    .button:hover {
    cursor: pointer;
    background: rgba(0,0,0,0.85);
    color: #fff;
    }

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <div class="slide-wrapper">
    <div id="slide1" class="slide">
    <h2>Slide One.</h2>
    </div>
    <div id="slide2" class="slide">
    <h2>Slide Two.</h2>
    </div>
    <div id="slide3" class="slide">
    <h2>Slide Three.</h2>
    </div>
    <div id="slide4" class="slide">
    <h2>Slide Four.</h2>
    </div>
    <div class="button-wrapper">
    <button id="prev" class="button">Prev.</button>
    <button id="next" class="button">Next.</button>
    </div>
    </div>












    share|improve this question



























      0












      0








      0








      I have developed a slideshow using jQuery that will pre-loade the next slide, hold the last one, and make the current slide active which adds a class with a delay.



      I predict there could be unnecessary duplication within the next and previous buttons. Are there improvements that can be made to the code, and if so, what would these be?






      $(document).ready(function(){

      $('.slide:eq(-1)').addClass('last');
      $('.slide:first').addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $('.slide:eq(1)').addClass('next');

      });

      // Previous Slide
      function prevSlide() {

      // Variables
      var $prevActive = $('.slide.active');
      var $prevSlide = $('.slide').eq(($prevActive.index() - 1) % $('.slide').length);
      var $afterPrevSlide = $('.slide').eq(($prevActive.index() - 2) % $('.slide').length);

      // Remove previous classes
      $prevActive.dequeue();
      $('.slide').removeClass('last active show-text next');

      // Add the new classes
      $prevActive.addClass('next');
      $prevSlide.addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $afterPrevSlide.addClass('last');

      }

      // Next Slide
      function nextSlide() {

      // Variables
      var $activeSlide = $('.slide.active');
      var $nextSlide = $('.slide').eq(($activeSlide.index() + 1) % $('.slide').length);
      var $slideAfterNext = $('.slide').eq(($activeSlide.index() + 2) % $('.slide').length);

      // Remove the previous classes
      $activeSlide.dequeue();
      $('.slide').removeClass('last active show-text next');

      // Add the new classes
      $activeSlide.addClass('last');
      $nextSlide.addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $slideAfterNext.addClass('next');

      }

      $('#prev').click(function(){

      prevSlide();

      });

      $('#next').click(function(){

      nextSlide();

      });

      body {
      font-size: 16px;
      font-family: 'Heebo', sans-serif;
      text-transform: uppercase;
      font-weight: 900;
      }

      /* Slides */
      .slide-wrapper {
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      display: flex;
      overflow: hidden;
      }

      .slide {
      position: absolute;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      width: 70%;
      left: 140%;
      z-index: 0;
      transition: 1.25s;
      box-shadow: -10px 0px 21px -5px rgba(0,0,0,0.5);
      }

      .slide h2 {
      display: none;
      color: #fff;
      text-shadow: 0px 0px 8px rgba(0,0,0,0.5);
      letter-spacing: -2px;
      font-size: 3rem;
      }

      .slide.active.show-text h2 {
      display: block;
      animation: reveal-text 1.5s forwards;
      }

      @keyframes reveal-text {
      0% { opacity: 0; }
      100% { opacity: 1; }
      }

      #slide1 {
      background: linear-gradient(to right, #93EDC7, #1CD8D2);
      }

      #slide2 {
      background: linear-gradient(to right, #4389A2, #5C258D);
      }

      #slide3 {
      background: linear-gradient(to right, #8E54E9, #4776E6);
      }

      #slide4 {
      background: linear-gradient(to right, #F45C43, #EB3349);
      }

      .slide.last {
      left: 0;
      z-index: 0;
      }

      .slide.active {
      left: 0;
      z-index: 1;
      }

      .slide.next {
      left: 70%;
      z-index: 2;
      }

      /* Buttons */
      .button-wrapper {
      display: flex;
      z-index: 10;
      width: 100%;
      justify-content: space-between;
      align-items: center;
      }

      .button {
      background-color: rgba(0,0,0,0.45);
      color: #ddd;
      height: 40px;
      border: none;
      font-weight: bold;
      padding: 10px 20px;
      transition: 0.3s;
      }

      .button:hover {
      cursor: pointer;
      background: rgba(0,0,0,0.85);
      color: #fff;
      }

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <div class="slide-wrapper">
      <div id="slide1" class="slide">
      <h2>Slide One.</h2>
      </div>
      <div id="slide2" class="slide">
      <h2>Slide Two.</h2>
      </div>
      <div id="slide3" class="slide">
      <h2>Slide Three.</h2>
      </div>
      <div id="slide4" class="slide">
      <h2>Slide Four.</h2>
      </div>
      <div class="button-wrapper">
      <button id="prev" class="button">Prev.</button>
      <button id="next" class="button">Next.</button>
      </div>
      </div>












      share|improve this question
















      I have developed a slideshow using jQuery that will pre-loade the next slide, hold the last one, and make the current slide active which adds a class with a delay.



      I predict there could be unnecessary duplication within the next and previous buttons. Are there improvements that can be made to the code, and if so, what would these be?






      $(document).ready(function(){

      $('.slide:eq(-1)').addClass('last');
      $('.slide:first').addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $('.slide:eq(1)').addClass('next');

      });

      // Previous Slide
      function prevSlide() {

      // Variables
      var $prevActive = $('.slide.active');
      var $prevSlide = $('.slide').eq(($prevActive.index() - 1) % $('.slide').length);
      var $afterPrevSlide = $('.slide').eq(($prevActive.index() - 2) % $('.slide').length);

      // Remove previous classes
      $prevActive.dequeue();
      $('.slide').removeClass('last active show-text next');

      // Add the new classes
      $prevActive.addClass('next');
      $prevSlide.addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $afterPrevSlide.addClass('last');

      }

      // Next Slide
      function nextSlide() {

      // Variables
      var $activeSlide = $('.slide.active');
      var $nextSlide = $('.slide').eq(($activeSlide.index() + 1) % $('.slide').length);
      var $slideAfterNext = $('.slide').eq(($activeSlide.index() + 2) % $('.slide').length);

      // Remove the previous classes
      $activeSlide.dequeue();
      $('.slide').removeClass('last active show-text next');

      // Add the new classes
      $activeSlide.addClass('last');
      $nextSlide.addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $slideAfterNext.addClass('next');

      }

      $('#prev').click(function(){

      prevSlide();

      });

      $('#next').click(function(){

      nextSlide();

      });

      body {
      font-size: 16px;
      font-family: 'Heebo', sans-serif;
      text-transform: uppercase;
      font-weight: 900;
      }

      /* Slides */
      .slide-wrapper {
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      display: flex;
      overflow: hidden;
      }

      .slide {
      position: absolute;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      width: 70%;
      left: 140%;
      z-index: 0;
      transition: 1.25s;
      box-shadow: -10px 0px 21px -5px rgba(0,0,0,0.5);
      }

      .slide h2 {
      display: none;
      color: #fff;
      text-shadow: 0px 0px 8px rgba(0,0,0,0.5);
      letter-spacing: -2px;
      font-size: 3rem;
      }

      .slide.active.show-text h2 {
      display: block;
      animation: reveal-text 1.5s forwards;
      }

      @keyframes reveal-text {
      0% { opacity: 0; }
      100% { opacity: 1; }
      }

      #slide1 {
      background: linear-gradient(to right, #93EDC7, #1CD8D2);
      }

      #slide2 {
      background: linear-gradient(to right, #4389A2, #5C258D);
      }

      #slide3 {
      background: linear-gradient(to right, #8E54E9, #4776E6);
      }

      #slide4 {
      background: linear-gradient(to right, #F45C43, #EB3349);
      }

      .slide.last {
      left: 0;
      z-index: 0;
      }

      .slide.active {
      left: 0;
      z-index: 1;
      }

      .slide.next {
      left: 70%;
      z-index: 2;
      }

      /* Buttons */
      .button-wrapper {
      display: flex;
      z-index: 10;
      width: 100%;
      justify-content: space-between;
      align-items: center;
      }

      .button {
      background-color: rgba(0,0,0,0.45);
      color: #ddd;
      height: 40px;
      border: none;
      font-weight: bold;
      padding: 10px 20px;
      transition: 0.3s;
      }

      .button:hover {
      cursor: pointer;
      background: rgba(0,0,0,0.85);
      color: #fff;
      }

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <div class="slide-wrapper">
      <div id="slide1" class="slide">
      <h2>Slide One.</h2>
      </div>
      <div id="slide2" class="slide">
      <h2>Slide Two.</h2>
      </div>
      <div id="slide3" class="slide">
      <h2>Slide Three.</h2>
      </div>
      <div id="slide4" class="slide">
      <h2>Slide Four.</h2>
      </div>
      <div class="button-wrapper">
      <button id="prev" class="button">Prev.</button>
      <button id="next" class="button">Next.</button>
      </div>
      </div>








      $(document).ready(function(){

      $('.slide:eq(-1)').addClass('last');
      $('.slide:first').addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $('.slide:eq(1)').addClass('next');

      });

      // Previous Slide
      function prevSlide() {

      // Variables
      var $prevActive = $('.slide.active');
      var $prevSlide = $('.slide').eq(($prevActive.index() - 1) % $('.slide').length);
      var $afterPrevSlide = $('.slide').eq(($prevActive.index() - 2) % $('.slide').length);

      // Remove previous classes
      $prevActive.dequeue();
      $('.slide').removeClass('last active show-text next');

      // Add the new classes
      $prevActive.addClass('next');
      $prevSlide.addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $afterPrevSlide.addClass('last');

      }

      // Next Slide
      function nextSlide() {

      // Variables
      var $activeSlide = $('.slide.active');
      var $nextSlide = $('.slide').eq(($activeSlide.index() + 1) % $('.slide').length);
      var $slideAfterNext = $('.slide').eq(($activeSlide.index() + 2) % $('.slide').length);

      // Remove the previous classes
      $activeSlide.dequeue();
      $('.slide').removeClass('last active show-text next');

      // Add the new classes
      $activeSlide.addClass('last');
      $nextSlide.addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $slideAfterNext.addClass('next');

      }

      $('#prev').click(function(){

      prevSlide();

      });

      $('#next').click(function(){

      nextSlide();

      });

      body {
      font-size: 16px;
      font-family: 'Heebo', sans-serif;
      text-transform: uppercase;
      font-weight: 900;
      }

      /* Slides */
      .slide-wrapper {
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      display: flex;
      overflow: hidden;
      }

      .slide {
      position: absolute;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      width: 70%;
      left: 140%;
      z-index: 0;
      transition: 1.25s;
      box-shadow: -10px 0px 21px -5px rgba(0,0,0,0.5);
      }

      .slide h2 {
      display: none;
      color: #fff;
      text-shadow: 0px 0px 8px rgba(0,0,0,0.5);
      letter-spacing: -2px;
      font-size: 3rem;
      }

      .slide.active.show-text h2 {
      display: block;
      animation: reveal-text 1.5s forwards;
      }

      @keyframes reveal-text {
      0% { opacity: 0; }
      100% { opacity: 1; }
      }

      #slide1 {
      background: linear-gradient(to right, #93EDC7, #1CD8D2);
      }

      #slide2 {
      background: linear-gradient(to right, #4389A2, #5C258D);
      }

      #slide3 {
      background: linear-gradient(to right, #8E54E9, #4776E6);
      }

      #slide4 {
      background: linear-gradient(to right, #F45C43, #EB3349);
      }

      .slide.last {
      left: 0;
      z-index: 0;
      }

      .slide.active {
      left: 0;
      z-index: 1;
      }

      .slide.next {
      left: 70%;
      z-index: 2;
      }

      /* Buttons */
      .button-wrapper {
      display: flex;
      z-index: 10;
      width: 100%;
      justify-content: space-between;
      align-items: center;
      }

      .button {
      background-color: rgba(0,0,0,0.45);
      color: #ddd;
      height: 40px;
      border: none;
      font-weight: bold;
      padding: 10px 20px;
      transition: 0.3s;
      }

      .button:hover {
      cursor: pointer;
      background: rgba(0,0,0,0.85);
      color: #fff;
      }

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <div class="slide-wrapper">
      <div id="slide1" class="slide">
      <h2>Slide One.</h2>
      </div>
      <div id="slide2" class="slide">
      <h2>Slide Two.</h2>
      </div>
      <div id="slide3" class="slide">
      <h2>Slide Three.</h2>
      </div>
      <div id="slide4" class="slide">
      <h2>Slide Four.</h2>
      </div>
      <div class="button-wrapper">
      <button id="prev" class="button">Prev.</button>
      <button id="next" class="button">Next.</button>
      </div>
      </div>





      $(document).ready(function(){

      $('.slide:eq(-1)').addClass('last');
      $('.slide:first').addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $('.slide:eq(1)').addClass('next');

      });

      // Previous Slide
      function prevSlide() {

      // Variables
      var $prevActive = $('.slide.active');
      var $prevSlide = $('.slide').eq(($prevActive.index() - 1) % $('.slide').length);
      var $afterPrevSlide = $('.slide').eq(($prevActive.index() - 2) % $('.slide').length);

      // Remove previous classes
      $prevActive.dequeue();
      $('.slide').removeClass('last active show-text next');

      // Add the new classes
      $prevActive.addClass('next');
      $prevSlide.addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $afterPrevSlide.addClass('last');

      }

      // Next Slide
      function nextSlide() {

      // Variables
      var $activeSlide = $('.slide.active');
      var $nextSlide = $('.slide').eq(($activeSlide.index() + 1) % $('.slide').length);
      var $slideAfterNext = $('.slide').eq(($activeSlide.index() + 2) % $('.slide').length);

      // Remove the previous classes
      $activeSlide.dequeue();
      $('.slide').removeClass('last active show-text next');

      // Add the new classes
      $activeSlide.addClass('last');
      $nextSlide.addClass('active').delay(1250).queue(function(){
      $(this).addClass('show-text');
      });
      $slideAfterNext.addClass('next');

      }

      $('#prev').click(function(){

      prevSlide();

      });

      $('#next').click(function(){

      nextSlide();

      });

      body {
      font-size: 16px;
      font-family: 'Heebo', sans-serif;
      text-transform: uppercase;
      font-weight: 900;
      }

      /* Slides */
      .slide-wrapper {
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      display: flex;
      overflow: hidden;
      }

      .slide {
      position: absolute;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      width: 70%;
      left: 140%;
      z-index: 0;
      transition: 1.25s;
      box-shadow: -10px 0px 21px -5px rgba(0,0,0,0.5);
      }

      .slide h2 {
      display: none;
      color: #fff;
      text-shadow: 0px 0px 8px rgba(0,0,0,0.5);
      letter-spacing: -2px;
      font-size: 3rem;
      }

      .slide.active.show-text h2 {
      display: block;
      animation: reveal-text 1.5s forwards;
      }

      @keyframes reveal-text {
      0% { opacity: 0; }
      100% { opacity: 1; }
      }

      #slide1 {
      background: linear-gradient(to right, #93EDC7, #1CD8D2);
      }

      #slide2 {
      background: linear-gradient(to right, #4389A2, #5C258D);
      }

      #slide3 {
      background: linear-gradient(to right, #8E54E9, #4776E6);
      }

      #slide4 {
      background: linear-gradient(to right, #F45C43, #EB3349);
      }

      .slide.last {
      left: 0;
      z-index: 0;
      }

      .slide.active {
      left: 0;
      z-index: 1;
      }

      .slide.next {
      left: 70%;
      z-index: 2;
      }

      /* Buttons */
      .button-wrapper {
      display: flex;
      z-index: 10;
      width: 100%;
      justify-content: space-between;
      align-items: center;
      }

      .button {
      background-color: rgba(0,0,0,0.45);
      color: #ddd;
      height: 40px;
      border: none;
      font-weight: bold;
      padding: 10px 20px;
      transition: 0.3s;
      }

      .button:hover {
      cursor: pointer;
      background: rgba(0,0,0,0.85);
      color: #fff;
      }

      <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <div class="slide-wrapper">
      <div id="slide1" class="slide">
      <h2>Slide One.</h2>
      </div>
      <div id="slide2" class="slide">
      <h2>Slide Two.</h2>
      </div>
      <div id="slide3" class="slide">
      <h2>Slide Three.</h2>
      </div>
      <div id="slide4" class="slide">
      <h2>Slide Four.</h2>
      </div>
      <div class="button-wrapper">
      <button id="prev" class="button">Prev.</button>
      <button id="next" class="button">Next.</button>
      </div>
      </div>






      algorithm jquery






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      Bagseye

















      asked yesterday









      BagseyeBagseye

      1436




      1436






















          0






          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f211319%2fjquery-slideshow-with-animation-callback%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Code Review Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f211319%2fjquery-slideshow-with-animation-callback%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Сан-Квентин

          Алькесар

          Josef Freinademetz