[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/HackedByChinese/ng2-idle/blob/master/CONTRIBUTING.md#getting-help
Current behavior
Currently, if I allow the idle period to start while my focus is in another window (such as another application besides my browser), the idle period will not end when I return to the browser, click around with the mouse, type keys, etc. It works as expected only if the user becomes idle while focus is inside the window, which is not desired, since most users will become idle while in other windows.
Expected behavior
The idle period should end regardless of where the focus was when it began.
Minimal reproduction of the problem with instructions
Take appropriate steps to activate ng2idle in your application (such as logging in).
Move the mouse to another window besides the browser and shift the focus there by clicking.
Wait for your application to become idle.
Move the mouse back into the application and click to move the focus back.
Click or type keys to end the idle status.
The application will not become active un-idle.
I'm using the following initialization:
init () {
let interruptSource: WindowInterruptSource = new WindowInterruptSource('mousemove keydown DOMMouseScroll mousewheel mousedown touchstart touchmove scroll');
// sets the default interrupts, in this case, things like clicks, scrolls, touches to the document
this.idle.setInterrupts([interruptSource, new StorageInterruptSource()]);
// Subscribe to idle events. Add your logic on how the application should respond, such as displaying
this.keepalive.onPing.subscribe(() => {
this.ngZone.run(() => {
console.log("In keepalive ping");
});
});
this.idle.onTimeout.subscribe(() => {
this.ngZone.run(() => {
console.log("The user would be logout now");
});
});
// a warning dialog onIdleStart, or redirecting to logout page onTImeout, etc.
this.idle.onIdleStart.subscribe(() => {
this.ngZone.run(() => {
console.log('IdleStart');
});
});
this.idle.onTimeoutWarning.subscribe((countdown) => {
this.ngZone.run(() => {
console.log("Countdown", countdown);
});
});
this.idle.onIdleEnd.subscribe(() => {
this.ngZone.run(() => {
console.log("Idle ended");
});
});
// start watching for idleness right away.
this.start();
}
start () {
this.ngZone.runOutsideAngular(() => {
this.idle.watch();
});
}
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
I'm using a Mac with Chrome, but have seen the same results on Browserstack emulating the Windows environment with both Chrome and Firefox.
@ng-idle version: 2.0.0-beta.11
Angular version: 2.4.1
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
I'm submitting a ... (check one with "x")
Current behavior
Currently, if I allow the idle period to start while my focus is in another window (such as another application besides my browser), the idle period will not end when I return to the browser, click around with the mouse, type keys, etc. It works as expected only if the user becomes idle while focus is inside the window, which is not desired, since most users will become idle while in other windows.
Expected behavior
The idle period should end regardless of where the focus was when it began.
Minimal reproduction of the problem with instructions
Take appropriate steps to activate ng2idle in your application (such as logging in). Move the mouse to another window besides the browser and shift the focus there by clicking. Wait for your application to become idle. Move the mouse back into the application and click to move the focus back. Click or type keys to end the idle status. The application will not become active un-idle.
I'm using the following initialization: init () { let interruptSource: WindowInterruptSource = new WindowInterruptSource('mousemove keydown DOMMouseScroll mousewheel mousedown touchstart touchmove scroll'); // sets the default interrupts, in this case, things like clicks, scrolls, touches to the document this.idle.setInterrupts([interruptSource, new StorageInterruptSource()]);
}
What is the motivation / use case for changing the behavior?
Please tell us about your environment:
I'm using a Mac with Chrome, but have seen the same results on Browserstack emulating the Windows environment with both Chrome and Firefox.
@ng-idle version: 2.0.0-beta.11
Angular version: 2.4.1
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
Chrome, Firefox
Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript
Node:
node --version
= 6.5.0EDIT: Seems related to https://github.com/HackedByChinese/ng2-idle/issues/40 - when not running
this.idle.watch
outside of ngZone, it seems to behave correctly - but then Protractor tests fail.