title: Make Background image move with mouse in Jquery
body: <p>I found this <a href="http://webmastereseller.com/background_mover/" rel="nofollow noreferrer">snippet of code</a>, and tweaked it a bit for my website:</p>
  
  <pre><code> var vH=jQuery('.categoryWrapper').height();
      var vW=jQuery('.categoryWrapper').width();
      var vT=jQuery('.categoryWrapper').offset().top;
      var vL=jQuery('.categoryWrapper').offset().left;
      jQuery('.categoryWrapper').mousemove(function(e){
          var ypos=e.pageY-vT;
          var xpos=e.pageX-vL;
          var y=Math.round(ypos/vW*100);
          var x=Math.round(xpos/vH*100);
  
          jQuery(this).css({backgroundPosition: x+'% '+y+'%'});
  </code></pre>
  
  <p>However, it's not quite doing what I want it to, and I am having a hard time tweaking this to work right.</p>
  
  <p>Go to <a href="http://photoshop.tutorialcraft.com" rel="nofollow noreferrer">http://photoshop.tutorialcraft.com</a> , and move your mouse over the "Photoshop Tutorials, "Graphic Inspiration", and "Graphic Downloads" buttons.</p>
  
  <p>Basically, I have a PNG file with a radial gradient. I want the background to track the mouse, but move a little faster than the mouse.</p>
  
  <p>For instance, <code>.categoryWrapper</code> is 312 x 88 pixels. The actually background img is 277x277. If I move my mouse in via the top of <code>.categoryWrapper</code>, the center of the bg IMG should be about 200px above the point where the mouse entered. As you move the mouse to the bottom, the background should move to about 200px below the mouse (that way the bg img appears and disappears when you move in and out).
  Below image should illustrate what I am trying to do:</p>
  
  <p><img src="https://i.stack.imgur.com/o9a2v.jpg" alt="enter image description here"></p>