home · contact · privacy
In web client, keep scrolling position even on focus change.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 13 Dec 2020 02:06:55 +0000 (03:06 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 13 Dec 2020 02:06:55 +0000 (03:06 +0100)
rogue_chat.html

index 6738e40755be0cd82ce284532dd8535c63672e5f..883afc9322ad994c260c3a422921f477c58fb2e7 100644 (file)
@@ -728,7 +728,6 @@ let tui = {
       this.mode_edit.available_actions = ["move", "flatten", "install",
                                           "toggle_map_mode"]
       this.inputEl = document.getElementById("input");
-      this.inputEl.focus();
       this.switch_mode('waiting_for_server');
       this.recalc_input_lines();
       this.height_header = this.height_turn_line + this.height_mode_line;
@@ -821,9 +820,6 @@ let tui = {
     } else if (this.mode.name != "edit") {
         this.map_mode = 'terrain + things';
     };
-    if (this.mode.has_input_prompt || this.mode.is_single_char_entry) {
-        this.inputEl.focus();
-    }
     if (game.player_id in game.things && (this.mode.shows_info || this.mode.name == 'control_tile_draw')) {
         explorer.position = game.player.position;
     }
@@ -1716,12 +1712,12 @@ window.setInterval(function() {
 }, 1000);
 window.setInterval(function() {
     if (document.activeElement.tagName.toLowerCase() != 'input') {
+        const scroll_x = window.scrollX;
+        const scroll_y = window.scrollY;
         tui.inputEl.focus();
+        window.scrollTo(scroll_x, scroll_y);
     };
 }, 100);
-document.getElementById("terminal").onclick = function() {
-    tui.inputEl.focus();
-};
 document.getElementById("help").onclick = function() {
     tui.show_help = true;
     tui.full_refresh();