I have this horizontal list of items
<section class="viewport">
<ul class="item-list">
<li class="item">A</li>
<li class="item">B</li>
...
</ul>
</section>
The list is movable in the horizontal direction (left/right). Checkout this jsfiddle Each item is of random width!
Now, assume that the item-list
element is moved. The question is, which item
is at the middle of the viewport ? A possible solution (not tested) is to calculate the offset of each element, subtract the movement, etc etc. But performance is very important, so I was wondering if someone knows a better solution ?
UPDATE: as a bonus question, how do you remove the space between the item
s. as is seen in the jsfiddle ?