从Ng-Idle中移除鼠标移动等事件



我正在使用Ng-Idle库来检查angular web应用中的用户不活动情况。

我已经实现了这么远的库

idle.setIdle(5);
idle.setTimeout(0);
idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
idle.onIdleEnd.subscribe(() => { 
this.idleState = 'No longer idle.'
console.log(this.idleState);
this.idle.watch();
this.idleState = 'Started.';
});
idle.onIdleStart.subscribe(() => {
this.idleState = 'You've gone idle!'
console.log(this.idleState);
});

问题是DEFAULT_INTERRUPTSOURCES接受了所有这些mousemove keydown dommousescroroll mousewheel mousedown touchstart touchmove scroll中断事件,但我想只有键盘和鼠标点击中断来停止ng-idle。

我试过改变这些库文件中的事件——>ng-idle-core.umd.js ng-idle-core.umd.js。map和ng-idle-core.metadata.json.仍然没有成功。

我怎样才能实现我想要的功能?

我通过以下代码获得了所需的结果

idle.setInterrupts(this.createCustomInterruptSources(null));
createCustomInterruptSources(options) {
return [
new DocumentInterruptSource('keydown mousedown touchstart touchmove 
scroll', options),
new StorageInterruptSource(options)
];
}

最新更新