From 581111e1a72b131eda3abe5fa324eb0730db7254 Mon Sep 17 00:00:00 2001 From: David Baker Date: Sat, 9 Jan 2016 00:06:54 +0000 Subject: [PATCH] Use wheel, not scroll as we get scroll events from auto scroll down. Also only do the cursor move check for mouse move events. --- src/UserActivity.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/UserActivity.js b/src/UserActivity.js index 6b918f0729..8b136c0bcc 100644 --- a/src/UserActivity.js +++ b/src/UserActivity.js @@ -33,7 +33,9 @@ class UserActivity { 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); + // also this needs to be the wheel event, not scroll, as scroll is + // fired when the view scrolls down for a new message. + window.addEventListener('wheel', this._onUserActivity.bind(this), true); this.lastActivityAtTs = new Date().getTime(); this.lastDispatchAtTs = 0; } @@ -44,11 +46,11 @@ class UserActivity { stop() { document.onmousemove = undefined; document.onkeypress = undefined; - window.removeEventListener('scroll', this._onUserActivity.bind(this), true); + window.removeEventListener('wheel', this._onUserActivity.bind(this), true); } _onUserActivity(event) { - if (event.screenX) { + if (event.screenX && event.type == "mousemove") { if (event.screenX === this.lastScreenX && event.screenY === this.lastScreenY) {