I'm trying to figure out a way to have multiple images on the same line extending past the div continue to scroll to the left until it's out of view at which point it would move to the end of the image gallery and continue to scroll again even if it's outside the view.
Here is the code I have so far. I game the images a class because I feel that would help but I'm not sure how yet.
html, body {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
overflow: hidden;
}
*, *::before, *::after {
box-sizing: border-box;
}
body {
background-color: black;
}
#permas {
height: 150px;
bottom: 0;
background: blue;
position: absolute;
overflow:hidden;
overflow-y: hidden;
white-space:nowrap;
}
#permas img {
height: 100%;
}
<html>
<head>
<title>Test site
</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div id="permas">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
</div>
<script src="main.js"></script>
</body>
</html>
As the images can have different aspect ratios it is quite messy to move just one image at a time to the back of the queue, and would require JavaScript intervention.
A similar method is to have exactly two copies of the images, to animate permas div element to move to the left by 50% of its width, i.e. to get all 10 images out of the way to the left, and have the viewport filled by the start of the second set.
Then get permas back to where it was initially and repeat.
There was some worry expressed in the comments that too much work would be needed. I have tested 10 images of different sizes and different content as well as the image given in the question and have found the GPU usage on my reasonably powerful laptop with Windows 10 to be pretty consistent around 20%. Of course, with lots more images (and possibly if some have natural dimensions very large, though I haven't tested that) there might be more processor time needed.
I haven't seen any jerkiness. You do have to be confident that the 10 images will more than cover the viewport width - but that assumption was also made in the question.
Here's the snippet with the original image:
html, body {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
overflow: hidden;
overflow: scroll;
}
*, *::before, *::after {
box-sizing: border-box;
}
body {
background-color: black;
}
#permas {
height: 150px;
bottom: 0;
background: blue;
position: absolute;
overflow:hidden;
overflow-y: hidden;
white-space:nowrap;
/* added */
left: 0;
animation-name: scroll;
animation-duration: 10s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
#permas img {
height: 100%;
}
@keyframes scroll {
0% {
transform: translateX(0);
}
100% {
transform: translateX(-50%);
}
}
<div id="permas">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
<img class="scroller" src="https://i.imgur.com/wURYltS.jpg">
</div>