I am trying to make round divs in the owner div. a overflow:hidden;. I am experiencing some problems with the mousemove event. Here is my example: jsFiddle , and that's my goal: ello.co . I also searched for some questions about mousemove, but I could not find vertically and horizontally together. HTML:
<div id="holder"><ul id="scroll">
<li><div class="si"></div></li>
<li><div class="si"></div></li><ul>
<li><div class="si"></div></li><ul>
</ul>
</ul></div>
CSS
#holder {
background: pink;
width: 500px;
height: 500px;
overflow:hidden;
line-height: 30px;
margin-left: 100px;
}
#scroll{
height: 30px;
line-height: 30px;
margin-left: 0;
padding: 0 10px;
}
#scroll li {
float: left;
padding: 0 5px;
}
.si{
width:150px;
height:150px;
background-color:black;
float:left;
border-radius:150px;
margin:10px;
}
.si:hover{
width:160px;
height:160px;
margin:2px;
}
JavaScript:
var sum = 0;
$("#scroll li").each(function() {
sum += $(this).width() + parseInt($(this).css('paddingLeft')) + parseInt($(this).css('paddingRight'))
});
$("#scroll").css('width', sum);
$("#holder").mousemove(function(e) {
x = -(((e.pageX - $('#scroll').position().left) / $("#holder").width()) * ($("#scroll").width() + parseInt($("#scroll").css('paddingLeft')) + parseInt($("#scroll").css('paddingRight')) - $("#holder").width()));
$("#scroll").css({
'marginLeft': x + 'px'
});
});
source
share