Fix editor scrolling issues

This commit is contained in:
Gnome Ann 2021-09-27 17:44:22 -04:00
parent 47c6f48e94
commit a327eed2c3
2 changed files with 8 additions and 6 deletions

View File

@ -1476,7 +1476,7 @@ def update_story_chunk(idx: Union[int, str]):
item = vars.acregex_ui.sub('<action>\\1</action>', item) # Add special formatting to adventure actions
chunk_text = f'<chunk n="{idx}" id="n{idx}" tabindex="-1">{formatforhtml(item)}</chunk>'
emit('from_server', {'cmd': 'updatechunk', 'data': {'index': idx, 'html': chunk_text, 'last': (idx == (vars.actions.get_last_key() if len(vars.actions) else 0))}}, broadcast=True)
emit('from_server', {'cmd': 'updatechunk', 'data': {'index': idx, 'html': chunk_text}}, broadcast=True)
#==================================================================#

View File

@ -947,6 +947,12 @@ function chunkOnSelectionChange(event) {
syncAllModifiedChunks();
setTimeout(function() {
highlightEditingChunks();
// Attempt to prevent Chromium-based browsers on Android from
// scrolling away from the current selection
setTimeout(function() {
game_text.blur();
game_text.focus();
}, 144);
}, 2);
}, 2);
}
@ -1096,7 +1102,7 @@ $(document).ready(function(){
scrollToBottom();
} else if(msg.cmd == "updatechunk") {
hideMessage();
const {index, html, last} = msg.data;
const {index, html} = msg.data;
const existingChunk = game_text.children(`#n${index}`)
const newChunk = $(html);
unbindGametext();
@ -1110,10 +1116,6 @@ $(document).ready(function(){
}
bindGametext();
hide([$('#curtain')]);
if(last) {
// Scroll to bottom of text if it's the last element
scrollToBottom();
}
} else if(msg.cmd == "removechunk") {
hideMessage();
let index = msg.data;