added a scrollbar to the command line

This commit is contained in:
Jack 2020-06-29 21:46:26 +01:00
parent 54038ea427
commit d4074fffdb
2 changed files with 36 additions and 30 deletions

View file

@ -322,6 +322,9 @@ a:hover {
line-height: 0.75rem;
}
.suggestions {
display: block;
overflow-y: scroll;
max-height: calc(100vh - 10rem - 3rem);
display: grid;
.entry {
padding: 0.5rem 1rem;

View file

@ -13,6 +13,33 @@ let commands = {
restartTest();
}
},
{
id: "changeMode",
display: "Change mode...",
subgroup: true,
exec: () => {
currentCommands.push(commandsMode);
showCommandLine();
}
},
{
id: "changeTimeConfig",
display: "Change time config...",
subgroup: true,
exec: () => {
currentCommands.push(commandsTimeConfig);
showCommandLine();
}
},
{
id: "changeWordCount",
display: "Change word count...",
subgroup: true,
exec: () => {
currentCommands.push(commandsWordCount);
showCommandLine();
}
},
{
visible: false,
id: "changeTags",
@ -98,7 +125,7 @@ let commands = {
},
{
id: "toggleColorfulMode",
display: "Toggle extra test color",
display: "Toggle colorful mode",
exec: () => {
toggleColorfulMode();
}
@ -114,7 +141,7 @@ let commands = {
},
{
id: "changeCaretStyle",
display: "Change caret...",
display: "Change caret style...",
subgroup: true,
exec: () => {
currentCommands.push(commandsCaretStyle);
@ -123,7 +150,7 @@ let commands = {
},
{
id: "changeTimerStyle",
display: "Change timer...",
display: "Change timer style...",
subgroup: true,
exec: () => {
currentCommands.push(commandsTimerStyle);
@ -166,33 +193,6 @@ let commands = {
showCommandLine();
}
},
{
id: "changeMode",
display: "Change mode...",
subgroup: true,
exec: () => {
currentCommands.push(commandsMode);
showCommandLine();
}
},
{
id: "changeTimeConfig",
display: "Change time config...",
subgroup: true,
exec: () => {
currentCommands.push(commandsTimeConfig);
showCommandLine();
}
},
{
id: "changeWordCount",
display: "Change word count...",
subgroup: true,
exec: () => {
currentCommands.push(commandsWordCount);
showCommandLine();
}
},
{
id: "joinDiscord",
display: "Join the Discord server",
@ -700,6 +700,9 @@ $(document).keydown((e) => {
hoverId = $(entries[activenum]).attr('command');
}
}
let scroll = Math.abs($('.suggestions').offset().top - $('.entry.activeKeyboard').offset().top - $('.suggestions').scrollTop()) - ($('.suggestions').outerHeight() / 2) + ($($('.entry')[0]).outerHeight());
$('.suggestions').scrollTop(scroll);
console.log(`scrolling to ${scroll}`);
try {
let list = currentCommands[currentCommands.length-1];
$.each(list.list, (index, obj) => {