2013-03-07 27 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); 
    }