Unfocus when mouse moves >5px (#2703)

* Update focus.ts

* Update focus.ts

* lowered threshold to be slightly more responsive

Co-authored-by: Miodec <bartnikjack@gmail.com>
This commit is contained in:
Justin K 2022-03-13 15:26:44 -07:00 committed by GitHub
parent 3528ba6c6c
commit c6de5c98ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
import * as Caret from "./caret";
import * as ActivePage from "../states/active-page";
const unfocusPx = 3;
let state = false;
export function set(foc: boolean, withCursor = false): void {
@ -28,7 +29,9 @@ $(document).mousemove(function (event) {
if (
$("#top").hasClass("focus") &&
event.originalEvent &&
(event.originalEvent.movementX > 0 || event.originalEvent.movementY > 0)
// To avoid mouse/desk vibration from creating a flashy effect, we'll unfocus @ >5px instead of >0px
(event.originalEvent.movementX > unfocusPx ||
event.originalEvent.movementY > unfocusPx)
) {
set(false);
}