How to make the change of images smoother in an image slideshow

Hi,

I am working on this page https://kroweb.dk/gfdev/

I have an automatic  slideshow at the top of the page. It is generally working as it is supposed to, except for the change of slides where the next slide is displayed kind of "hard".
What I am after here is that the change of slides displays like a soft ease out of the actual slide and a simultaneously soft ease in of the next slide.

Anybody who have ideas :)

The actual slideshow code is this:
<style>
* {box-sizing: border-box;}
body {font-family: Verdana, sans-serif;}
.mySlides {display: none;}
img {vertical-align: middle;}

/* Slideshow container */
.slideshow-container {
  max-width: 1000px;
  position: relative;
  margin: auto;
}

/* Caption text */
.text {
  display: none;  
  color: #f2f2f2;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}

/* Number text (1/3 etc) */
.numbertext {
  display: none;  
  color: #f2f2f2;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}

/* The dots/bullets/indicators */
.dot {
  
  height: 15px;
  width: 15px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
  display: none;  
}

.active {
  background-color: #717171;
}

/* Fading animation */
.fade {
  -webkit-animation-name: fade;
  -webkit-animation-dealy: 1000;
  -webkit-animation-duration: 3s;
  -webkit-transition-timing-function: ease-in;
  animation-name: fade;
  animation-dealy: 1000;
  animation-duration: 3s;
  transition-timing-function: ease-in;
}

@-webkit-keyframes fade {
  from {opacity: -1} 
  to {opacity: 1}
}

@keyframes fade {
  from {opacity: -1} 
  to {opacity: 1}
}

/* On smaller screens, decrease text size */
@media only screen and (max-width: 300px) {
  .text {font-size: 11px}
}
</style>


<div class="slideshow-container">

<div class="mySlides fade">
  <div class="numbertext">1 / 3</div>
  <img src="https://genealogiskforum.dk/images/GF træf2012 profil 1200x400.jpg" style="width:100%">
  <div class="text">Caption Text</div>
</div>

<div class="mySlides fade">
  <div class="numbertext">2 / 3</div>
  <img src="https://genealogiskforum.dk/images/GF træf2013 profil 1200x400.jpg" style="width:100%">
  <div class="text">Caption Two</div>
</div>

<div class="mySlides fade">
  <div class="numbertext">3 / 3</div>
  <img src="https://genealogiskforum.dk/images/GF træf2014 profil 1200x400.jpg" style="width:100%">
  <div class="text">Caption Three</div>
</div>

</div>
<br>

<div style="text-align:center">
  <span class="dot"></span> 
  <span class="dot"></span> 
  <span class="dot"></span> 
</div>

<script>
var slideIndex = 0;
showSlides();

function showSlides() {
    var i;
    var slides = document.getElementsByClassName("mySlides");
    var dots = document.getElementsByClassName("dot");
    for (i = 0; i < slides.length; i++) {
       slides[i].style.display = "none";  
    }
    slideIndex++;
    if (slideIndex > slides.length) {slideIndex = 1}    
    for (i = 0; i < dots.length; i++) {
        dots[i].className = dots[i].className.replace(" active", "");
    }
    slides[slideIndex-1].style.display = "block";  
    dots[slideIndex-1].className += " active";
    setTimeout(showSlides, 5000); // Change image every 2 seconds
}
</script>



    </div>

Open in new window

Peter KromanSales ExecutiveAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Leonidas DosasCommented:
See this CSS transitions.I use classes hidden and visible to hide and show.I use addClass or removeClass
CSS:
.visible
               {
                       visibility: visible;
                       opacity: 1;
                       transition: opacity 2s linear;
               }                
               /* Fade-Out Effect */
               .hidden
               {
                       visibility: hidden;
                       opacity: 0;
                       transition: visibility 0s 2s, opacity 2s linear;
               }

Open in new window


Sample Code below:
<!DOCTYPE html>
<html>
<head>
<title>HTML, CSS and JavaScript demo</title>
  <style>
   .visible
               {
                       visibility: visible;
                       opacity: 1;
                       transition: opacity 2s linear;
               }                
               /* Fade-Out Effect */
               .hidden
               {
                       visibility: hidden;
                       opacity: 0;
                       transition: visibility 0s 2s, opacity 2s linear;
               }                
               #wrapper > div
               {
                       background: none repeat scroll 0 0 #f5f;
                       border: 5px solid #808080;
                       border-radius: 50px;
                       padding: 10px;
                       width: 250px;
               }
  </style>
</head>
<body>
<!-- Start your code here -->

<div id="wrapper">
               <p>
                       <button type="button">Show HTML Element</button>
                       <button type="button">Hide HTML Element</button>
               </p>
               <br />
               <div class="hidden">
                       Hello Peter
               </div>
       </div>
  <script>
     var showButtonClick = document.querySelector("#wrapper button:nth-of-type(1)"),
                       hideButtonClick = document.querySelector("#wrapper button:nth-of-type(2)"),
                       content = document.querySelector("#wrapper > div");
               //Show wrapper div content
               showButtonClick.addEventListener("click", function () {
                       content.className = "visible";
               }, false);

               //Hide wrapper div content
               hideButtonClick.addEventListener("click", function () {
                       content.className = "hidden";
               }, false);
  </script>
<!-- End your code here -->
</body>
</html>

Open in new window

0
Peter KromanSales ExecutiveAuthor Commented:
Thanks Leonidas,

I'll work with it and get back to you
0
Peter KromanSales ExecutiveAuthor Commented:
Hi again,

I can't get it working right. Could I aks you to give me an example with a couple of images that slides automatically (no buttons) and with the nice fade-in and fade-out look :)
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Peter KromanSales ExecutiveAuthor Commented:
Hi again,

I have managed to make a much simpler code that the first one I posted.
And it is working nicely :)

HTML:
<div id="slideshow">
       <div>
         <img src="https://genealogiskforum.dk/images/GF træf2012 profil 1200x400.jpg" width="100%">
       </div>
       <div>
         <img src="https://genealogiskforum.dk/images/GF træf2013 profil 1200x400.jpg" width="100%">
       </div>
       <div>
         <img src="https://genealogiskforum.dk/images/GF træf2014 profil 1200x400.jpg" width=100%>
       </div>
       <div>
         <img src="https://genealogiskforum.dk/images/Gf træf2015 profil 1200x400.jpg" width="100%">
       </div>
       <div>
         <img src="https://genealogiskforum.dk/images/GF træf2016 profil 1200x400.jpg" width="100%">
       </div>
       <div>
         <img src="https://genealogiskforum.dk/images/Gf træf2017 profil 1200x400.jpg" width="100%">
       </div>
    </div>

Open in new window


CSS:
#slideshow { 
    position: relative; 
    width: 100%; 
    
}

#slideshow > div { 
    position: absolute; 
    top: 10px; 
    left: 10px; 
    right: 10px; 
    bottom: 10px; 
}

Open in new window


JQuery, JS
$("#slideshow > div:gt(0)").hide();

        setInterval(function() { 
          $('#slideshow > div:first')
            .fadeOut(2500)
            .next()
            .fadeIn(2500)
            .end()
            .appendTo('#slideshow');
        },  5000);

Open in new window

0
Leonidas DosasCommented:
Yes... it works nice and smoothly.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Peter KromanSales ExecutiveAuthor Commented:
Thanks for leading me in the right direction on this one :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.