Search code examples
javascriptjqueryweb-applicationsyelp

Yelp mouse tracking mechanism


I realized Yelp.com does some kind of tracking when the mouse move or something happens (click in element). How does it to this? Is there a library? How to do this without nearly zero performance impact?

You can see Console in Firebug below:

enter image description here


Solution

  • A very basic implementation of the mouse tracking could look like this: http://jsfiddle.net/pksah/

    HTML:

    <body>
        <div id="container"></div>
    </body>
    

    JS:

    currentPosition = null;
    $("#container").on("mousemove", function (event) {
        currentPosition = event;
    });
    
    
    setInterval(function () {
        console.log(currentPosition.pageX + "," + currentPosition.pageY);
    }, 1000)
    

    CSS:

    #container {
        width:100%;
        height:300px;
        background:yellow;
    }