@@ -4766,6 +4766,11 @@ Current version indicated by LITEVER below.
47664766 //setup drag and drop zone for files
47674767 setupDragDrop();
47684768
4769+ //setup autoscroll disabling when manual scroll
4770+ attach_scroll_detection(document.getElementById("gametext"));
4771+ attach_scroll_detection(document.getElementById("chat_msg_body"));
4772+ attach_scroll_detection(document.getElementById("corpostylemain"));
4773+
47694774 //fix for iphone zooming
47704775 if(navigator.userAgent.indexOf('iPhone') > -1 )
47714776 {
@@ -21910,15 +21915,19 @@ Current version indicated by LITEVER below.
2191021915
2191121916 }
2191221917
21918+ var autoscrollEnabled = true;
21919+ var suppressScrollEvent = false;
21920+ var autoscrollTimeout = null;
2191321921 function handle_autoscroll(alwaysscroll=true)
2191421922 {
2191521923 if (localsettings.autoscroll) {
2191621924 let box1 = document.getElementById("gametext");
2191721925 let box2 = document.getElementById("chat_msg_body");
2191821926 let box3 = document.getElementById("corpostylemain");
2191921927 function isScrolledToBottom(element) {
21920- return element.scrollHeight - element.scrollTop - element.clientHeight <= 100 ;
21928+ return element.scrollHeight - element.scrollTop - element.clientHeight <= (autoscrollEnabled?220:60) ;
2192121929 }
21930+ suppressScrollEvent = true;
2192221931 if(alwaysscroll || isScrolledToBottom(box1))
2192321932 {
2192421933 box1.scrollTop = box1.scrollHeight - box1.clientHeight + 10;
@@ -21931,8 +21940,22 @@ Current version indicated by LITEVER below.
2193121940 {
2193221941 box3.scrollTop = box3.scrollHeight - box3.clientHeight + 10;
2193321942 }
21943+ suppressScrollEvent = false;
2193421944 }
2193521945 }
21946+ function attach_scroll_detection(element)
21947+ {
21948+ element.addEventListener("scroll", () => {
21949+ if (suppressScrollEvent) { return; }
21950+ autoscrollEnabled = false;
21951+ if (autoscrollTimeout) {
21952+ clearTimeout(autoscrollTimeout);
21953+ }
21954+ autoscrollTimeout = setTimeout(() => {
21955+ autoscrollEnabled = true;
21956+ }, 100);
21957+ });
21958+ }
2193621959
2193721960 function render_gametext(save=true, force_scroll=true)
2193821961 {
@@ -25868,7 +25891,9 @@ Current version indicated by LITEVER below.
2586825891 const containerRect = gametext.getBoundingClientRect();
2586925892 if (rect.top < containerRect.top || rect.bottom > containerRect.bottom) {
2587025893 if (range.startContainer && range.startContainer.nodeType === Node.TEXT_NODE) {
25894+ suppressScrollEvent = true;
2587125895 gametext.scrollTop = 0; //simple fix for safari scrolling
25896+ suppressScrollEvent = false;
2587225897 const span = document.createElement("span");
2587325898 span.style.display = "inline";
2587425899 span.style.background = "transparent";
0 commit comments