I have made a controllable carousel with the following code.
HTML
<div id = "blanket">
<div id = "carousel">
<img id = "cr" src = "img/cr.png"/>
<img id = "te" src = "img/te.png"/>
<img id = "mi" src = "img/mi.png"/>
<img id = "ga" src = "img/ga.png"/>
<img id = "ro" src = "img/ro.png"/>
</div>
</div>
CSS
#carousel{
height: 100%;
width: 500%;
}
#carousel img{
position: relative;
display: inline-block;
height: 100%;
width: 20%;
border:1px solid white;
}
#blanket{
position: relative;
display: inline-block;
float: right;
right: 5%;
top:7%;
height: 75%;
width:64%;
overflow: hidden;
background: rgba(0,0,0,0.3);
}
jS(jQuery & GSAP included)
$(document).ready(function() {
})
$(document).click(function() {
var i = event.target.id;
if(i=="yl"){
gets(0);
}
else if(i=="gt"){
gets(1);
}
else if(i=="br"){
gets(2);
}
else if(i=="rb"){
gets(3);
}
else if(i=="gb"){
gets(4);
}
});
function gets(i) {
var off = -1 * (i * $('#carousel img').width());
TweenLite.to($('#carousel img'), 0.7 ,{left:off+"px",ease:Power2.easeOut});
}
The problem is that the carousel does not move in sync with the images ie. some pixels of the previous image creep into the next pane. What to do?