Elements "jerk" back to right when I change their order
<p>I am trying to create an infinite scroll of elements, and haven't found a plugin that was sufficiently lightweight/capable enough, so I'm trying to create my own.</p>

<p>So far it is working swimmingly, except for a slight jerkiness in the animation when I remove the first element and append it to the end of the parent. The example I've tossed up also has an issue where the elements lose their padding, for some reason, but that is not occurring in my actual code...</p>

<p><strong>Fiddle:</strong>
<a href="http://jsfiddle.net/WtFWy/" rel="nofollow">http://jsfiddle.net/WtFWy/</a></p>

<p><strong>Using the sample markup:</strong></p>

<pre><code>&lt;section id="photos" class="bg-transparent-black"&gt;
    &lt;div class="red"&gt;&lt;/div&gt;
    &lt;div class="blue"&gt;&lt;/div&gt;
    &lt;div class="green"&gt;&lt;/div&gt;
&lt;/section&gt;​

#photos{
    position:absolute;
    bottom:1em;
    width:100px;
    height:225px;
    padding:3px;
    overflow:hidden;
    white-space:nowrap;
}
#photos div{
    height:100%;
    width:50px;
    padding:3px;
    display:inline-block;
    position:relative;
    border:1px solid black;
}
.red{background:red;}
.blue{background:blue;}
.green{background:green;}
</code></pre>

<p>​
<strong>And JavaScript:</strong></p>

<pre><code>scrollImages = function(){
                var photoArea = $('#photos');
                var children = photoArea.children();
                var firstChild = $(children[0])
                var firstOffset=firstChild.offset();
                if(document.elementLeft === false){
                    document.elementLeft = firstOffset.left;
                }
                if(document.elementWidth === false){
                    document.elementWidth=firstChild.outerWidth(true);
                }
                if(firstOffset.left &lt; 0 &amp;&amp; (Math.abs(firstOffset.left) &gt; Math.abs(document.elementWidth))){
                    photoArea.append(firstChild);
                    firstChild.css('margin-left', 0 + 'px')
                    children = photoArea.children();
                    firstChild = $(children[0])
                    firstOffset=firstChild.offset();
                    document.elementLeft = firstOffset.left;
                    document.elementWidth=firstChild.outerWidth(true);
                }else{

                }
                document.elementLeft -= 1;
                firstChild.css('margin-left', document.elementLeft + 'px');
                t = setTimeout(scrollImages, 100);

            }
            document.elementLeft = false;
            document.elementWidth = false;
            var t = setTimeout(scrollImages, 500);
            $('#photos').mouseover(function(){clearTimeout(t)});
            $('#photos').mouseout(function(){scrollImages()})
        });
</code></pre>

<p>​</p>
