Adjust auto-scroll code to use more compatible APIs, adding support for macOS Catalina fix-autoscroll
author<kcochran@trolans.net>
Sat, 19 Oct 2019 17:34:22 -0700
branchfix-autoscroll
changeset 5995 2bfcb17b7076
parent 5989 1b816aafafdd
child 5996 1894c44cfd13
Adjust auto-scroll code to use more compatible APIs, adding support for macOS Catalina
Plugins/WebKit Message View/Template.html
Resources/Message Styles/Renkoo.AdiumMessageStyle/Contents/Resources/Footer.html
--- a/Plugins/WebKit Message View/Template.html	Wed Oct 16 20:22:26 2019 +0100
+++ b/Plugins/WebKit Message View/Template.html	Sat Oct 19 17:34:22 2019 -0700
@@ -214,10 +214,10 @@
 
 		//Auto-scroll to bottom.  Use nearBottom to determine if a scrollToBottom is desired.
 		function nearBottom() {
-			return ( document.body.scrollTop >= ( document.body.offsetHeight - ( window.innerHeight * 1.2 ) ) );
+			return ( window.scrollY >= ( document.body.offsetHeight - ( window.innerHeight * 1.2 ) ) );
 		}
 		function scrollToBottom() {
-			document.body.scrollTop = document.body.offsetHeight;
+			window.scrollTo(0, document.body.scrollHeight);
 		}
 
 		//Dynamically exchange the active stylesheet
--- a/Resources/Message Styles/Renkoo.AdiumMessageStyle/Contents/Resources/Footer.html	Wed Oct 16 20:22:26 2019 +0100
+++ b/Resources/Message Styles/Renkoo.AdiumMessageStyle/Contents/Resources/Footer.html	Sat Oct 19 17:34:22 2019 -0700
@@ -184,10 +184,10 @@
 		if ( intervall_scroll ) clearInterval( intervall_scroll );
 		intervall_scroll = setInterval( function() {
 			var target_scroll = (document.body.scrollHeight-window.innerHeight);
-			var scrolldiff = target_scroll - document.body.scrollTop;
-			if ( document.body.scrollTop != target_scroll ) {
-				var saved_scroll = document.body.scrollTop;
-				document.body.scrollTop += scrolldiff / 5 + ( scrolldiff >= 0 ? (scrolldiff != 0 ) : -1 );
+			var scrolldiff = target_scroll - window.scrollY;
+			if ( window.scrollY != target_scroll ) {
+				var saved_scroll = window.scrollY;
+				window.scrollTo(0, window.scrollY + scrolldiff / 5 + ( scrolldiff >= 0 ? (scrolldiff != 0 ) : -1 ));
 			} else {
 				saved_scroll = -1;
 				clearInterval( intervall_scroll );