mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-18 19:45:58 +08:00
using debounce
This commit is contained in:
parent
038d7b3717
commit
5ddf832c02
1 changed files with 6 additions and 2 deletions
|
@ -4,6 +4,7 @@ import * as Notifications from "./elements/notifications";
|
|||
import * as CustomText from "./test/custom-text";
|
||||
import * as TestActive from "./states/test-active";
|
||||
import * as ConfigEvent from "./observables/config-event";
|
||||
import { debounce } from "throttle-debounce";
|
||||
|
||||
export function updateKeytips(): void {
|
||||
if (Config.swapEscAndTab) {
|
||||
|
@ -75,11 +76,14 @@ window.addEventListener("beforeunload", (event) => {
|
|||
}
|
||||
});
|
||||
|
||||
$(window).on("resize", () => {
|
||||
console.log("Updating caret position");
|
||||
const debouncedCaretUpdate = debounce(250, () => {
|
||||
Caret.updatePosition();
|
||||
});
|
||||
|
||||
$(window).on("resize", () => {
|
||||
debouncedCaretUpdate();
|
||||
});
|
||||
|
||||
ConfigEvent.subscribe((eventKey) => {
|
||||
if (eventKey === "swapEscAndTab") updateKeytips();
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue