title: How do you slow down counting iterations in a loop?
body: <p>I am working on a PowerShell GUI and I am animating a few control item events. I can get it to work the way that I want but I want it to slow down and be a little more deliberate.</p>
  
  <p>I understand that with many languages it ties in with clock speed and that isn't going to change. Most resources online have to do with speeding up scripts or programs.</p>
  
  <p>To give an example of what I am talking about:</p>
  
  <pre><code>$button.Add_MouseEnter({
      0..30 | %{
          $button.Location = "$_,100"
          }
      })
  $button.Add_MouseLeave({
      30..0 | %{
          $button.Location = "$_,100"
          }
      })
  </code></pre>
  
  <p>This will move the button to the right 30 units when the mouse hovers over the button and, when the mouse leaves the button, it will shift over 30 units to the left to its original location.</p>
  
  <p>Problem for me is that iterating the 31 numbers (<code>0..30</code>) is done very quickly and it snaps in the animation. I would like to have that particular event action perform slower however, the problem is that if I were to extend the iterations, it pushes the button further out which is not what I would need.</p>
  
  <p>I was laying in bed last night and I realized that this may work but I was wondering if there were any other ways to accomplish this in PowerShell.</p>
  
  <pre><code>0..5000 | %{
      if($_.ToString().EndsWith(00)) {
          $increment++
          $button.Location = "$increment,100"
          }
      }
  </code></pre>
  
  <p>I tried integrating it into the script but it dramatically slowed down performance (instead of using 5000, I used 50000), so, I'm all ears for suggestions.</p>
  
  <p>Thanks!</p>