2013-03-07 29 views

回答

0

我现在已经找到了解决方案。在空闲timer.js,我更新了它作为跟随 1 /搜索跟踪代码

var idle = false,  //indicates if the user is idle 
     tId  = -1,   //timeout ID 
     enabled = false,  //indicates if the idle timer is enabled 
     timeout = 30000;  //the amount of time (ms) before the user is considered idle 

,并在接下来的上述

prevMousePos = { x: -1, y: -1 }; 
     currentMousePos = { x: -1, y: -1 }; 

如果你的代码没有工作添加两个以下行,你可以尝试event.screenX,event.screenY。

2 /替换这一行

clearTimeout(tId); 

if(e.type == 'mousemove'){ 
      currentMousePos.x = event.pageX; 
      currentMousePos.y = event.pageY; 
      if(currentMousePos == prevMousePos){ 
       enabled = false; 
      } 
      else{ 
       prevMousePos = currentMousePos; 
       clearTimeout(tId); 
      } 
     } 
     else if(e.type == 'mousemove'){ 
      clearTimeout(tId); 
     } 

    else if(e.type == 'keydown'){ 
     clearTimeout(tId); 
    }