mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-20 09:25:53 +00:00
autoscroll fixes
This commit is contained in:
parent
6aa79513a9
commit
b30f09db80
1 changed files with 26 additions and 1 deletions
|
|
@ -4766,6 +4766,11 @@ Current version indicated by LITEVER below.
|
|||
//setup drag and drop zone for files
|
||||
setupDragDrop();
|
||||
|
||||
//setup autoscroll disabling when manual scroll
|
||||
attach_scroll_detection(document.getElementById("gametext"));
|
||||
attach_scroll_detection(document.getElementById("chat_msg_body"));
|
||||
attach_scroll_detection(document.getElementById("corpostylemain"));
|
||||
|
||||
//fix for iphone zooming
|
||||
if(navigator.userAgent.indexOf('iPhone') > -1 )
|
||||
{
|
||||
|
|
@ -21910,6 +21915,9 @@ Current version indicated by LITEVER below.
|
|||
|
||||
}
|
||||
|
||||
var autoscrollEnabled = true;
|
||||
var suppressScrollEvent = false;
|
||||
var autoscrollTimeout = null;
|
||||
function handle_autoscroll(alwaysscroll=true)
|
||||
{
|
||||
if (localsettings.autoscroll) {
|
||||
|
|
@ -21917,8 +21925,9 @@ Current version indicated by LITEVER below.
|
|||
let box2 = document.getElementById("chat_msg_body");
|
||||
let box3 = document.getElementById("corpostylemain");
|
||||
function isScrolledToBottom(element) {
|
||||
return element.scrollHeight - element.scrollTop - element.clientHeight <= 100;
|
||||
return element.scrollHeight - element.scrollTop - element.clientHeight <= (autoscrollEnabled?220:60);
|
||||
}
|
||||
suppressScrollEvent = true;
|
||||
if(alwaysscroll || isScrolledToBottom(box1))
|
||||
{
|
||||
box1.scrollTop = box1.scrollHeight - box1.clientHeight + 10;
|
||||
|
|
@ -21931,8 +21940,22 @@ Current version indicated by LITEVER below.
|
|||
{
|
||||
box3.scrollTop = box3.scrollHeight - box3.clientHeight + 10;
|
||||
}
|
||||
suppressScrollEvent = false;
|
||||
}
|
||||
}
|
||||
function attach_scroll_detection(element)
|
||||
{
|
||||
element.addEventListener("scroll", () => {
|
||||
if (suppressScrollEvent) { return; }
|
||||
autoscrollEnabled = false;
|
||||
if (autoscrollTimeout) {
|
||||
clearTimeout(autoscrollTimeout);
|
||||
}
|
||||
autoscrollTimeout = setTimeout(() => {
|
||||
autoscrollEnabled = true;
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
function render_gametext(save=true, force_scroll=true)
|
||||
{
|
||||
|
|
@ -25868,7 +25891,9 @@ Current version indicated by LITEVER below.
|
|||
const containerRect = gametext.getBoundingClientRect();
|
||||
if (rect.top < containerRect.top || rect.bottom > containerRect.bottom) {
|
||||
if (range.startContainer && range.startContainer.nodeType === Node.TEXT_NODE) {
|
||||
suppressScrollEvent = true;
|
||||
gametext.scrollTop = 0; //simple fix for safari scrolling
|
||||
suppressScrollEvent = false;
|
||||
const span = document.createElement("span");
|
||||
span.style.display = "inline";
|
||||
span.style.background = "transparent";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue