Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
tiger2005 committed May 6, 2022
1 parent f9cc3ab commit 84d37eb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ body.at_desktop {
position: absolute;
border-radius: 0px;
background: var(--tick-background);
border-radius: 3px;
}

.tickDisplayer.left .oneTick, .tickDisplayer.right .oneTick{
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Keyboard_Overlay",
"version": "0.2.0",
"version": "0.2.1",
"main": "main.js",
"dependencies": {
"app": "^0.1.0",
Expand Down
20 changes: 19 additions & 1 deletion scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
let useKps = false;
let majorFontSize = 14;
let tickSpeed = 10;
let isReady = false;

let directoryLocation = undefined;

Expand Down Expand Up @@ -242,6 +243,9 @@
p = 2 * len + p;
p = Math.max(p, 0.05 * (moveTime * majorFontSize));
ele.css("width", Math.ceil(p));
setTimeout(() => {
ele.css("width", Math.ceil(p));
}, 20);
setTimeout(() => {
ele.remove();
delete animationEnd[tkIdx];
Expand Down Expand Up @@ -269,6 +273,9 @@
p = len - p;
p = Math.max(p, 0.05 * (moveTime * majorFontSize));
ele.css("width", Math.ceil(p));
setTimeout(() => {
ele.css("width", Math.ceil(p));
}, 20);
setTimeout(() => {
ele.remove();
delete animationEnd[tkIdx];
Expand Down Expand Up @@ -296,6 +303,9 @@
p = 2 * len + p;
p = Math.max(p, 0.05 * (moveTime * majorFontSize));
ele.css("height", Math.ceil(p));
setTimeout(() => {
ele.css("height", Math.ceil(p));
}, 20);
setTimeout(() => {
ele.remove();
delete animationEnd[tkIdx];
Expand Down Expand Up @@ -323,6 +333,9 @@
p = len - p;
p = Math.max(p, 0.05 * (moveTime * majorFontSize));
ele.css("height", Math.ceil(p));
setTimeout(() => {
ele.css("height", Math.ceil(p));
}, 20);
setTimeout(() => {
ele.remove();
delete animationEnd[tkIdx];
Expand All @@ -336,6 +349,8 @@
let cpsCount = 0;
let keyboardLocked = false;
const keydownEvent = (e, wheel) => {
if(! isReady)
return;
const ck = (typeof e === "string" ? e : (runInElectron ? e.keycode : e.code));
if(keyboardLocked){
if(codeToKey[ck] === undefined)
Expand Down Expand Up @@ -487,6 +502,8 @@
}
};
const keyupEvent = (e, wheel) => {
if(! isReady)
return;
if(keyboardLocked)
return;
const ck = (typeof e === "string" ? e : (runInElectron ? e.keycode : e.code));
Expand Down Expand Up @@ -1080,7 +1097,8 @@
if(displayShortcut)
$(".shortcutKeyContainer").css("display", "block");
if(runInElectron)
win.setSize(Math.ceil($(".innerContent").outerWidth()), Math.ceil($(".innerContent").outerHeight()));
win.setSize(Math.floor($(".innerContent").outerWidth()), Math.floor($(".innerContent").outerHeight()));
isReady = true;
},
error: function(){
setErrorMessage("Cannot load map file.");
Expand Down

0 comments on commit 84d37eb

Please sign in to comment.