Tracking Mouse Stop

Posted by Hallik on Stack Overflow See other posts from Stack Overflow or by Hallik
Published on 2010-04-28T17:00:42Z Indexed on 2010/04/28 17:03 UTC
Read the original article Hit count: 349

Filed under:

I am trying to track mouse movements in the browser, and if a user stops their mouse for 0.5 seconds, to execute some code. I have put a breakpoint in the code below in firebug, and it breaks on the var mousestop = function(evt) line, but then jumps to the return statement. Am I missing something simple? Why isn't it executing the POST statement? I am tracking mouse clicks in a similar way, and it posts to the server just fine. Just not mouse stops.

$.fn.saveStops = function() {
$(this).bind('mousemove.clickmap', function(evt) {
    var mousestop = function(evt) {
          $.post('/heat-save.php', {  
                x:evt.pageX,  
                y:evt.pageY,
                click:"false",
                w:window.innerWidth,
                h:window.innerHeight,
                l:escape(document.location.pathname) 
            }); 
      }, 
      thread;

      return function() {
        clearTimeout(thread);
        thread = setTimeout(mousestop, 500);
      };

});
};

© Stack Overflow or respective owner

Related posts about jQuery