From 1c4d1d250783b6eeaf15f8479eccf02f278b0d97 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 8 Jan 2016 22:19:31 +0000 Subject: [PATCH] Make scrolling count as user activity. --- src/UserActivity.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/UserActivity.js b/src/UserActivity.js index 3048ad4454..6b918f0729 100644 --- a/src/UserActivity.js +++ b/src/UserActivity.js @@ -31,6 +31,9 @@ class UserActivity { start() { document.onmousemove = this._onUserActivity.bind(this); document.onkeypress = this._onUserActivity.bind(this); + // can't use document.scroll here because that's only the document + // itself being scrolled. Need to use addEventListener's useCapture. + window.addEventListener('scroll', this._onUserActivity.bind(this), true); this.lastActivityAtTs = new Date().getTime(); this.lastDispatchAtTs = 0; } @@ -41,6 +44,7 @@ class UserActivity { stop() { document.onmousemove = undefined; document.onkeypress = undefined; + window.removeEventListener('scroll', this._onUserActivity.bind(this), true); } _onUserActivity(event) {