From ba090a6ad53897dfe28d2bfc06cbdbff57b9e22d Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 29 Nov 2015 15:39:10 +0000 Subject: [PATCH] only dispatch user_activity event if the mouse actually moves (rather than the DOM moving under the mouse) --- src/UserActivity.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/UserActivity.js b/src/UserActivity.js index cee1b4efe2..b283b9a58e 100644 --- a/src/UserActivity.js +++ b/src/UserActivity.js @@ -43,7 +43,18 @@ class UserActivity { document.onkeypress = undefined; } - _onUserActivity() { + _onUserActivity(event) { + if (event.screenX) { + if (event.screenX === this.lastScreenX && + event.screenY === this.lastScreenY) + { + // mouse hasn't actually moved + return; + } + this.lastScreenX = event.screenX; + this.lastScreenY = event.screenY; + } + this.lastActivityAtTs = (new Date).getTime(); if (this.lastDispatchAtTs < this.lastActivityAtTs - MIN_DISPATCH_INTERVAL) { this.lastDispatchAtTs = this.lastActivityAtTs;