Fix slow typing speed on mobile devices

This commit is contained in:
Gnome Ann 2021-09-30 17:52:35 -04:00
parent a923b3bfa7
commit 00c1f49ca1
1 changed files with 11 additions and 3 deletions

View File

@ -977,7 +977,7 @@ function chunkOnPaste(event) {
}
// This gets run every time the caret moves in the editor
function chunkOnSelectionChange(event) {
function _chunkOnSelectionChange(event, do_blur_focus) {
if(!gametext_bound || !allowedit || override_focusout) {
override_focusout = false;
return;
@ -988,7 +988,7 @@ function chunkOnSelectionChange(event) {
highlightEditingChunks();
// Attempt to prevent Chromium-based browsers on Android from
// scrolling away from the current selection
if(!using_webkit_patch) {
if(do_blur_focus && !using_webkit_patch) {
setTimeout(function() {
game_text.blur();
game_text.focus();
@ -998,6 +998,14 @@ function chunkOnSelectionChange(event) {
}, 2);
}
function chunkOnSelectionChange(event) {
return _chunkOnSelectionChange(event, true);
}
function chunkOnKeyDownSelectionChange(event) {
return _chunkOnSelectionChange(event, false);
}
// This gets run when you defocus the editor by clicking
// outside of the editor or by pressing escape or tab
function chunkOnFocusOut(event) {
@ -1432,7 +1440,7 @@ $(document).ready(function(){
).on('click',
chunkOnSelectionChange
).on('keydown',
chunkOnSelectionChange
chunkOnKeyDownSelectionChange
).on('focusout',
chunkOnFocusOut
);