<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Aggiungere tasto pause/play a slideshow javascript]]></title><description><![CDATA[<p dir="auto">Buonasera a tutti, avrei bisogno di aiuto per aggiungere un pulsante ad un semplice slideshow con autoplay per poterlo fermarlo e riavviare manualmente. Grazie mille per l'aiuto.<br />
Il codice è questo:</p>
<p dir="auto">CSS:</p>
<pre><code>*, *:before, *:after {
  -webkit-box-sizing: border-box;
  -o-box-sizing: border-box;
  box-sizing: border-box;
}

img {
  max-width: 100%;
}
/* Slideshow container */
.slideshow-container {
  max-width: 800px;
  position: relative;
  margin: 40px auto;
  width: 100%;
  overflow: hidden;
}

.slideshow-nav {
  text-align: center;
  width: 100%;
  position: absolute;
  bottom: 2%;
}

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

.active, .dot:hover {
  background-color: #ff0000;
}

/* Next &amp; previous buttons */
.prev, .next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  padding: 6px;
  color: #fff;
  color: rgba(255, 255, 255, 0.5);
  font-weight: bold;
  font-size: 3.0rem;
  border-radius: 0 3px 3px 0;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
  -webkit-transition: 0.6s ease-out;
  -moz-transition: 0.6s ease-out;
  -o-transition: 0.6s ease-out;
  transition: 0.6s ease-out;
}

/* Position the "next button" to the right */
.next {
  right: 0;
  border-radius: 3px 0 0 3px;
}

.prev:hover, .next:hover {
  background-color: black;
  color: white;
  cursor: pointer;
}

.fadeIn {
  -webkit-animation-name: fadeIn;
  animation-name: fadeIn;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

@-webkit-keyframes fadeIn {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}
</code></pre>
<p dir="auto">HTML:</p>
<pre><code class="language-html">&lt;!-- start slider --&gt;
      &lt;div class="slideshow-container"&gt;
         &lt;!--Slide 1--&gt;
         &lt;div class="mySlides fadeIn"&gt;
            &lt;img src="01.jpg"&gt;
         &lt;/div&gt;
         &lt;!--Slide 2--&gt;
         &lt;div class="mySlides fadeIn"&gt;
            &lt;img src="02.jpg"&gt;
         &lt;/div&gt;
         &lt;!--Slide 3--&gt;
         &lt;div class="mySlides fadeIn"&gt;
            &lt;img src="03.jpg"&gt;
         &lt;/div&gt;
         &lt;!--Silde 4--&gt;
         &lt;div class="mySlides fadeIn"&gt;
            &lt;img src="04.jpg"&gt;
         &lt;/div&gt;
         &lt;a class="prev" onclick="plusSlides(-2);"&gt;&amp;#10094;&lt;/a&gt;
         &lt;a class="next" onclick="plusSlides(0)"&gt;&amp;#10095;&lt;/a&gt;
         &lt;div class="slideshow-nav"&gt;
            &lt;span class="dot" onclick="currentSlide(0)"&gt;&lt;/span&gt;
            &lt;span class="dot" onclick="currentSlide(1)"&gt;&lt;/span&gt;
            &lt;span class="dot" onclick="currentSlide(2)"&gt;&lt;/span&gt;
            &lt;span class="dot" onclick="currentSlide(3)"&gt;&lt;/span&gt;
         &lt;/div&gt;
      &lt;/div&gt;
</code></pre>
<p dir="auto">JAVASCRIPT:</p>
<pre><code>var slideIndex = 1;
  var millis = 5000;
  var interval;
  var timeout;

  startSlides();
  function startSlides(){
    pauseSlides();
    nextSlide();
    interval = setInterval(nextSlide, millis);
  }
  function resumeSlides() {
    nextSlide();
  }
  function pauseSlides() {
    clearInterval(interval);
  }
  function nextSlide() {
    showSlide();
    slideIndex++;
  }
  function plusSlides(n) {
    clearInterval(interval);
    clearTimeout(timeout);
    slideIndex += n;
    nextSlide();
    timeout = setTimeout(startSlides, millis * 2)
  }
  function currentSlide(n) {
    clearInterval(interval);
    slideIndex = n + 1;
    nextSlide();
    interval = setInterval(nextSlide, millis);
  }
  function showSlide() {
    var i;
    var slides = document.getElementsByClassName("mySlides");
    var dots = document.getElementsByClassName("dot");
    for (i = 0; i &lt; slides.length; i++) {
      slides[i].style.display = "none";
    }
    if (slideIndex &gt; slides.length) {
      slideIndex = 1;
    }
    if (slideIndex &lt; 1) {
      slideIndex = slides.length;
    }
    for (i = 0; i &lt; dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
    }
    slides[slideIndex - 1].style.display = "block";
    dots[slideIndex - 1].className += " active";
  }
</code></pre>
]]></description><link>https://dev.connect.gt/topic/239414/aggiungere-tasto-pause-play-a-slideshow-javascript</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 00:11:58 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/239414.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Dec 2019 15:36:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Aggiungere tasto pause/play a slideshow javascript on Wed, 11 Dec 2019 15:03:25 GMT]]></title><description><![CDATA[<p dir="auto">Grazie mille flaviors, dovrebbe funzionare, ci lavoro..</p>
]]></description><link>https://dev.connect.gt/post/1261281</link><guid isPermaLink="true">https://dev.connect.gt/post/1261281</guid><dc:creator><![CDATA[cosina]]></dc:creator><pubDate>Wed, 11 Dec 2019 15:03:25 GMT</pubDate></item><item><title><![CDATA[Reply to Aggiungere tasto pause/play a slideshow javascript on Wed, 11 Dec 2019 11:34:29 GMT]]></title><description><![CDATA[<p dir="auto">Ciao,</p>
<p dir="auto">aggiungi questo codice nell'HTML, dovrebbe andare</p>
<pre><code class="language-html">&lt;input type="button" value="Pause" onclick="javascript:if ('Play' === this.value) {this.value = 'Pause'; startSlides();} else {this.value = 'Play'; pauseSlides();}"&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/post/1261275</link><guid isPermaLink="true">https://dev.connect.gt/post/1261275</guid><dc:creator><![CDATA[flaviors200]]></dc:creator><pubDate>Wed, 11 Dec 2019 11:34:29 GMT</pubDate></item></channel></rss>