Copy link to clipboard
Copied
I have attached a project using devextreme. In that project, I have implemented automatic logout feature. But its work wrongly. It automatically move to home page from view page, when device is inactive or active. That means resetTimer is not working. I have checked online. But still I didn't get proper solution to that problem.
I have used following code.
function setup() {
window.addEventListener("mousemove", resetTimer, false);
window.addEventListener("mousedown", resetTimer, false);
window.addEventListener("keypress", resetTimer, false);
window.addEventListener("DOMMouseScroll", resetTimer, false);
window.addEventListener("mousewheel", resetTimer, false);
window.addEventListener("touchmove", resetTimer, false);
window.addEventListener("MSPointerMove", resetTimer, false);
startTimer();
}
function startTimer() {
timeoutID = window.setTimeout(goInactive, 5000);
}
function resetTimer(e) {
if (typeof timeoutID === "number") {
if (Application5.app.navigationManager._currentItem.uri != 'home' && timeoutID) {
window.clearTimeout(timeoutID);
timeoutID = null;
goActive();
}
}
}
function goActive() {
startTimer();
}
function goInactive() {
Application5.app.navigate("home", { target: "current" });
}
It have worked well in android mobile
Have something to add?