title: jQuery .position().left and variables
body: <p>How do I make it so the slider only slides left till the "red" slide and right till the "green" slide with the jQuery below? I feel like I am missing something simple, but I am not seeing it as of now. The moveLeft function appears to work, but moveRight does not.</p>
  
  <pre><code>var slideWidth = $('#mySliderContainer').width();
  var slideCountWidth = $('#mySlider').children().length;
  
  var min = 0;
  var max = -(slideCountWidth -1) * slideWidth;
  
  function moveLeft() {
    $('#mySlider').animate({
      left: '+='+slideWidth
    }, 400);
    if($('#mySlider').position().left &gt;= min) {
      $('#mySlider').animate({left: '-='+slideWidth});
    }
  };
  
  function moveRight() {
    $('#mySlider').animate({
      left: '-='+slideWidth
    }, 400);
    if($('#mySlider').position().left &lt;= max) {
      $('#mySlider').animate({left: '+='+slideWidth});
    }
  };
  </code></pre>
  
  <p>The link to where the jQuery is being implemented is located on this <a href="http://jsfiddle.net/andrewwierzba/uhtxtnks/" rel="nofollow">jsFiddle</a>.</p>
  
  <p>Ideally, if you try to go past the min and max slides, it should bounce back (either to the "red" or "green" slide). I am obviously doing something wrong with this bit of code.</p>
  
  <pre><code>var max = -(slideCountWidth -1) * slideWidth;
  </code></pre>