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