After creating a photo slider and implementing some w3 CSS to display a photo modal upon clicking an image in the slider, I encountered an issue. When the JavaScript code tries to slide the slider, it disrupts the modal if it is open. Is there a way to pause the JavaScript when the modal is opened?
Here is my PHP code:
function getSlideshow($conn) {
$sql = "SELECT * FROM status WHERE status_image!='noimage.png' ORDER BY likes DESC LIMIT 8";
$query = mysqli_query($conn, $sql);
$i = 0;
while ($row = $query->fetch_assoc()) {
if($i % 4 == 0 && $i) echo "</div>";
if($i % 4 == 0) echo "<div class='inner'>";
echo "
<div class='imagebox'>
<img src='images/".$row['status_image']."' onclick='document.getElementById(\"modal".$row['sid']."\").style.display=\"block\"' class='w3-hover-opacity'>
</div>
<div id='modal".$row['sid']."' class='w3-modal' onclick='this.style.display=\"none\"'>
<span class='w3-closebtn w3-hover-green w3-container w3-padding-16 w3-display-topright'>×</span>
<div class='w3-modal-content w3-animate-zoom'>
<img src='images/".$row['status_image']."' style='width:100%'>
</div>
</div>
";
$i++;
}
if($i % 4) echo '</div>';
}
And here is the JS/JQuery code:
$("#slideshow1h > .inner:gt(0)").hide();
setInterval(function() {
$('#slideshow1h > .inner:first')
.fadeOut(1500)
.next()
.fadeIn(1500)
.end()
.appendTo('#slideshow1h');
}, 6000);