angular - 从 Ng-Idle 中删除 mousemove 等事件
问题描述
我正在使用 Ng-Idle 库来检查用户在 angular webapp 中的不活动情况。
我已经实现了这么远的库
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 DOMMouseScroll mousewheel mousedown touchstart touchmove 滚动中断事件,但我只希望键盘和鼠标单击中断来停止 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)
];
}
推荐阅读
- angular - 提交表单编辑值 ngForm
- ruby - 使用Ruby中的过滤从数组中删除重复的数组项
- excel - EXCEL, Bloomberg : 如何从股票代码中获取 CDS 代码
- angular - Angular 2~6:与“组件”通信的最有效方式是什么?
- glassfish - 下载 Glassfish 服务器 3.1.2.15
- laravel - 如何在 Voyager 中更改文件上传路径
- python-3.x - 恢复后的张量流批量标准化
- electron - 在关闭回调时访问远程窗口内的窗口
- c# - 依赖注入刷新缓存
- authentication - Hyperledger Composer Rest Server 与 Cloudant 的连接