//Throttle: $(function() { var throttleOn = false; var actionLock = false; var throttleTimer = 100; function throttle(e) { if (throttleOn) { actionLock = true; }; if (!actionLock) { throttleOn = true; setTimeout(function() { throttleOn = false; }, throttleTimer); translate(e); }; actionLock = false; }; //Tracking: var threshold = 20; var box = $(".kvbox"); function translate(e) { var xOrigin = box.width() / 2; var yOrigin = box.height() / 2; var xPivot = (e.clientY - yOrigin) / yOrigin * -threshold; var yPivot = (e.clientX - xOrigin) / xOrigin * threshold; box.css({ 'transform': 'translate(-50%, -50%) rotateX(' + xPivot + 'deg) rotateY(' + yPivot + 'deg)' }); }; //Handler: $(window).mousemove(function(e) { throttle(e); }); });