Note that there are some explanatory texts on larger screens.

plurals
  1. POAnimation not working with outer loop
    primarykey
    data
    text
    <p>I am trying to perform some jquery animation on images, their positions and dimensions. What I'm trying to do is move the image clicked to the position of the Biggest Image(Position 1,p1, image). </p> <p>What I have been able to do so far is rotate every image to the next forward position.</p> <p>You can see in this <a href="http://jsfiddle.net/7HZ6L/" rel="nofollow">fiddle</a>.</p> <p>What I have tried to do is to place the function <code>movement</code> inside a loop like so</p> <pre><code>for(var x = 0; x &lt; 3; x++){ movement(checker); } </code></pre> <p>At first thought I expected it to jus move every element 3 positions forward but that wasn't the case. Nothing noticeable happened. NB: <code>checker</code> is id number of the clicked image.</p> <p>I've also thought that making the <code>movement</code> function go on more than the number of element(16) would also cause it to somewhat solve the problem. I change it to 32 expecting each element to move 2 positions.</p> <pre><code>function movement(checker){ var count = 1; var first, last, positions, dimensions, leftPos, topPos, imgWidth, imgHeight; while(count&lt;=32){//Increasing the loops to 32 from 16 if(checker == 0){ checker = 16; } first = d.e("p"+checker); if(checker == 1){ last = d.e("p"+16); }else{ last = d.e("p"+(checker-1)); } //console.log(checker); positions = findPos(last); dimensions = getCanvas(last); leftPos = positions[0]; topPos = positions[1]; imgWidth = dimensions[0]; imgHeight = dimensions[1]; $("#p"+checker).animate({"left":leftPos, "top":topPos, "width":imgWidth, "height":imgHeight}, "fast"); checker--; count++; } </code></pre> <p>I am at a lost of what to do now. Ideally what I want to do is put it in a loop that would have the parameters "continue until checker left and top positions == left and top positions of p1(initial)".</p> <p>So my problem is getting the elements to move more than one position on the click. I'm not sure if I'm taking the right approach at this but any help would be appreciated.</p> <p>Thank you in advance. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload