From f360cf6276992993ecc31df88807b767b84790d0 Mon Sep 17 00:00:00 2001 From: ebolam Date: Tue, 11 Oct 2022 10:59:11 -0400 Subject: [PATCH] Fix for infinite scroll --- static/koboldai.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/static/koboldai.js b/static/koboldai.js index b31400a7..3045d568 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -529,9 +529,15 @@ function var_changed(data) { if ((data.classname == 'actions') && (data.name == 'Action Count')) { current_action = data.value; if (current_action <= 0) { + console.log("setting action_count to "+current_action); document.getElementById("story_prompt").classList.remove("hidden"); scroll_trigger_element = undefined; document.getElementById("Selected Text").onscroll = undefined; + } else if (Math.min.apply(null,Object.keys(actions_data).map(Number).filter(function(x){return x>0})) > 0) { + //we have actions and our minimum action we have in the UI is above the start of the game + //we need to keep the story prompt hidden + document.getElementById("story_prompt").classList.add("hidden"); + } } //Special Case for Actions @@ -4693,6 +4699,8 @@ function infinite_scroll() { } function run_infinite_scroll_update(action_type, actions, first_action) { + console.log("action_type: "+action_type); + console.log("first_action: "+first_action); if (action_type == "append") { if (document.getElementById('Selected Text Chunk '+actions[actions.length-1].id)) { document.getElementById('Selected Text Chunk '+actions[actions.length-1].id).scrollIntoView(false); @@ -4700,6 +4708,8 @@ function run_infinite_scroll_update(action_type, actions, first_action) { } //Check to see if we need to have the scrolling in place or not if (document.getElementById("story_prompt").classList.contains("hidden")) { + console.log("Appending, but adding infinite scroll"); + console.log(document.getElementById('Selected Text Chunk '+Math.min.apply(null,Object.keys(actions_data).map(Number).filter(function(x){return x>0})))); document.getElementById("Selected Text").onscroll = infinite_scroll; scroll_trigger_element = document.getElementById('Selected Text Chunk '+Math.min.apply(null,Object.keys(actions_data).map(Number).filter(function(x){return x>0}))); }