After spending countless hours trying to troubleshoot my code, I am now seeking help from the wonderful people of the internet! ;) It seems like only a small portion of my code is incorrect. What I'm attempting to do is move the leftmost object in the container off-screen and then append it to the last item in the container to create a continuous scrolling effect. Currently, I have only three elements to test if this functionality works. Can you spot what I'm doing wrong?
Here is my HTML:
<section class="photo-grid-slideshow">
<div class="photo-crop">
<h3>I wanna
<div class="xs-spacer"></div>
<a class="med-btn btn-white">Read more</a>
</h3>
<div class="photo-grid-container" style="background-image: url('Images and videos/odesza1.jpg');"></div>
</div>
<div class="photo-crop">
<h3>Dance
<div class="xs-spacer"></div>
<a class="med-btn btn-white">Read more</a>
</h3>
<div class="photo-grid-container" style="background-image: url('Images and videos/odesza3.jpg');"></div>
</div>
<div class="photo-crop">
<h3>With you
<div class="xs-spacer"></div>
<a class="med-btn btn-white">Read more</a>
</h3>
<div class="photo-grid-container" style="background-image: url('Images and videos/odesza2.png');"></div>
</div>
</section>
And here is my CSS:
.photo-crop {
display: inline-block;
overflow: hidden;
float: left;
width: calc(100% / 3);
height: 100%;
line-height: 100%;
margin: 0;
margin-right: 0;
padding: 0;
display: inline-block;
position: relative;
left: 0;
right: 0;
background-position: center center;
background-size: cover;
transition: all 0.2s;
text-align: left;
}
.photo-grid-slideshow {
height: 300px;
display: inline-block;
min-width: 100%;
position: relative;
background: black;
padding: none;
overflow: hidden;
background: #444;
}
Lastly, my JavaScript looks like this:
$(function () {
var timer = setInterval(function() {
$(".photo-crop:first-child").animate({marginLeft: '-=33vw'}, 2000, "linear", function() {
$('this').Css("margin-left", 0).appendTo('.photo-crop:last-child');
});
}, 2000);
});