changeset 901:1cff36303150

Handling of the option for "scrollIntoView" changed
author HIROSE Yuuji <yuuji@gentei.org>
date Sat, 02 Jan 2021 19:23:17 +0900
parents 1fa8b4440f8f
children d9ecb727edcd
files s4-main.js
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/s4-main.js	Sat Jan 02 19:13:27 2021 +0900
+++ b/s4-main.js	Sat Jan 02 19:23:17 2021 +0900
@@ -165,14 +165,13 @@
 	ajaxSubmit.textContent = ajaxSubmit.back;
 	ajaxSubmit.disabled = false;
 	console.log("Update "+cnt+"rows");
-	if (cnt>0)
+	if (cnt>0 && ntr.scrollIntoView) {
+	    let option = {behavior: "smooth"};
+	    if (!isOlderJS) option.block = "center";
 	    try {	// Scroll to last updated row
-		ntr.scrollIntoView({behavior: "smooth", block: "center"});
-	    } catch (e1) {
-		try {	// block: "center" is not supported by older agents
-		    ntr.scrollIntoView({behavior: "smooth"});
-		} catch (e2) {}
-	    } 
+		ntr.scrollIntoView(option);
+	    } catch (e1) {}
+	}
 	return cnt;
     }
 

yatex.org