javascript - position not being set properly on page load
<p>I am creating a coverflow plugin but I have a slight problem when it first loads.</p>

<p>The size/styles of the images is set based on their position in the coverflow. When the page first loads the images all resize properly but they do not reposition themselves. If I them use the left and right navigation they work correctly.</p>

<p>I am not sure what is causing this. I thought it might be something to do with the variable that sets the starting position of the coverflow...</p>

<p>Here's my code:</p>



<pre><code>    &lt;script type="text/javascript" src="/scripts/jquery-ui.js"&gt;&lt;/script&gt;

    &lt;script type="text/javascript"&gt;

        $(document).ready(function() {

            var coverflowPos = Math.round($('#coverflow img').length / 2)

            $('#coverflow img').each( function(i) {
                $(this).css({'opacity' : 1-(Math.abs(coverflowPos-i)*0.4), 'z-index' : 100-(Math.abs(coverflowPos-i)) }).width(200-(Math.abs(coverflowPos-i)*50)).height(128-(Math.abs(coverflowPos-i)*50));
            });

// If I run the testme() function here, it animates to the right place but I want it to start in this position rather than animate to it

            $('#moveLeft').click( function() {
                if(coverflowPos &gt; 1) {
                    coverflowPos = coverflowPos-1
                }
                testme();
            });

            $('#moveRight').click( function() {
                if(coverflowPos &lt; $("#coverflow img").length -1) {
                    coverflowPos = coverflowPos+1
                }
                testme();
            });

            function testme() {
                $('#coverflow img').each( function(i) {
                    $(this).animate({
                        opacity: 1-(Math.abs(coverflowPos-i)*0.4),
                        width: 200-(Math.abs(coverflowPos-i)*50),
                        height: 128-(Math.abs(coverflowPos-i)*50)
                    }, {
                        duration: 500,
                        easing: 'easeInOutSine'
                    }).css({ 'z-index' : 100-(Math.abs(coverflowPos-i)) });
                });

            };

        });

    &lt;/script&gt;
</code></pre>

<p>And here's a link to a jsfiddle:</p>

<p><a href="http://jsfiddle.net/r8NqP/4/" rel="nofollow">http://jsfiddle.net/r8NqP/4/</a></p>
