-1

I'm using Ng-Idle library for keeping check of user inactivity in a angular webapp.

I'm implemented library this much far

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);
});

The problem is that the DEFAULT_INTERRUPTSOURCES takes all these mousemove keydown DOMMouseScroll mousewheel mousedown touchstart touchmove scroll interrupt events but I want only keyboard and mouse click interrupts to stop ng-idle.

I've tried changing the events from these library files ---> ng-idle-core.umd.js, ng-idle-core.umd.js.map and ng-idle-core.metadata.json. Still no success.

How can I achieve the desired functionality?

viveksinghal
  • 21
  • 1
  • 3

1 Answers1

1

I got the desired results by following code

idle.setInterrupts(this.createCustomInterruptSources(null));

createCustomInterruptSources(options) {
  return [
      new DocumentInterruptSource('keydown mousedown touchstart touchmove 
      scroll', options),
      new StorageInterruptSource(options)
  ];
}
viveksinghal
  • 21
  • 1
  • 3