JSFiddle - React, Tailwind, and code Playground
HTML
<div id="main">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
<img src="http://dummyimage.com/150x100/000/fff">
</div>
CSS
div {
overflow-x:scroll;
overflow-y:hidden;
white-space:nowrap;
}
JavaScript
$('#main').scroll(function (event) {
var factor = this.scrollLeft / (this.scrollWidth - $(this).width());
if(factor < 0.2) {
var move = $(this.lastChild);
move.remove();
$(this).prepend(move);
this.scrollLeft += move.width();
} else if(factor > 0.8) {
var move = $(this.firstChild);
move.remove();
$(this).append(move);
this.scrollLeft -= move.width();
}
});