JSFiddle - React, Tailwind, and code Playground

HTML

<div id="container">
<div id="mask">
    <div id="images">
        <img id="a" src="http://lorempixel.com/output/cats-q-c-150-150-1.jpg" data-width="150"  data-h="130">
        <img id="b" src="http://lorempixel.com/output/cats-h-c-100-150-5.jpg" data-width="100" data-h="130">
        <img id="c" src="http://lorempixel.com/output/food-q-c-200-150-5.jpg" data-width="200" data-h="130">
        <img id="d" src="http://lorempixel.com/output/sports-q-c-170-150-4.jpg" data-width="170" data-h="130">
        <img id="e" src="http://lorempixel.com/output/people-q-c-220-150-8.jpg" data-width="220" data-h="130">
        <img id="f" src="http://lorempixel.com/output/city-q-c-180-150-7.jpg" data-width="180" data-h="130"> 
        <img id="g" src="http://lorempixel.com/output/transport-q-c-220-150-1.jpg" data-width="220" data-h="130">
    </div>
</div>
    <a href="#" class="prev">&lt;</a>
    <a href="#" class="next">&gt;</a>   
</div>

CSS

#container{
	height: 200px;
	/*width: 650px;*/
	margin:100px auto;
	background-color: #CCC;
	padding-top:5px;
	position:relative;
}

#mask{
	height: 162px;
	/*width: 450px;*/
	/*width: 486px;*/
	overflow: hidden;
	position: relative;
	margin:25px auto;
}

#images{
	position:absolute;
	left:0px;
	top:0px;
}

#images img{
	float: left;
	background-color:#E6E6E6;
	padding:3px;
	border:1px solid #939393;
	margin:2px;
}


 a {
    display: block;
    height: 40px;
    width: 30px;
    font-size: 24px;
    line-height: 1.6;
    font-weight: 800;
    color: #222;
    background-color: rgb(255,99,71);
    background-color: rgba(255,99,71,0.7);
    text-decoration: none;
    padding: 0 4px;
    position: absolute;
    top: 50%;
    margin-top: -20px;
    text-align: center;
    z-index: 10;
}

 a.prev {
    left: 0;
    -webkit-border-top-right-radius: 4px;
    -webkit-border-bottom-right-radius: 4px;
    -moz-border-radius-topright: 4px;
    -moz-border-radius-bottomright: 4px;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

 a.next {
    right: 0;
    -webkit-border-top-left-radius: 4px;
    -webkit-border-bottom-left-radius: 4px;
    -moz-border-radius-topleft: 4px;
    -moz-border-radius-bottomleft: 4px;
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

JavaScript

var wid=0
	var maskWidth=0
	var arr=[]
	$('#images img').each(function(i){
		wid+=parseInt($(this).attr('data-width'))
		arr.push($(this).attr('data-width'))
		if(i<3){maskWidth+=parseInt($(this).attr('data-width'))}
		})
	//set container width =	3* mor larger image
	var biggest = Math.max.apply( null, arr )*3;
	$('#container').css('width',biggest+'px')
	//set mask width= width of first 3 images
	$('#mask').css({'width':(maskWidth+36)+'px'})
	
	//set images width=width of all images
	$('#images').css({'width':wid+'px'})
	//set attribute data-last on thirdi image
	$('#images img:eq(2)').attr('data-pos','last')
	
	
	
	//next and prev click are differnent for the position of image div
	$('.next').click(function(e){
		e.preventDefault()
		var widthx=$('#mask').width()
		var next=parseInt($('#images').find('img[data-pos="last"]').next('img').attr('data-width'))+12
		$('#images').find('img[data-pos="last"]').next('img').attr('data-pos','last')
		$('#images').find('img[data-pos="last"]:first').removeAttr('data-pos')
		var ind=$('#images').find('img[data-pos="last"]').index()+1
		var collection=$('#images').find('img').slice(ind-3,ind)
		var newWidth=0
		 $(collection).map( function( i, element ) {
			 newWidth+= parseInt($(element).data( 'width' )+12);
		 });
		 var diff=widthx-newWidth	
		 var delta=parseInt(next)+(diff)
		 $('#images').animate({'left':'-='+(delta)+'px'},1000 )
		 $('#mask').animate({'width':(newWidth)+'px'},1000,function(){
			 $('img:first').appendTo('#images')
			 $('#images').css({'left':'0px'}) 
		})
	})
		
	$('.prev').click(function(e){
		e.preventDefault()
		var widthx=$('#mask').width()
		$('img:last').prependTo('#images')
		var largh=parseInt($('img:first').attr('data-width'))+12
		$('#images').css({'left':largh*-1+'px'})
		var collection=$('#images').find('img').slice(0,3)
		var newWidth=0
		 $(collection).map( function( i, element ) {
			 newWidth+= parseInt($(element).data( 'width' )+12);
		 });
	    ...