Browse Source

平滑滚动到中间

visuddhinanda 2 years ago
parent
commit
7f21cf8458
1 changed files with 7 additions and 1 deletions
  1. 7 1
      dashboard/src/components/template/SentEdit/SentCell.tsx

+ 7 - 1
dashboard/src/components/template/SentEdit/SentCell.tsx

@@ -60,7 +60,13 @@ const SentCellWidget = ({
   useEffect(() => {
   useEffect(() => {
     if (anchorInfo && anchorInfo?.resId === initValue?.id) {
     if (anchorInfo && anchorInfo?.resId === initValue?.id) {
       const ele = document.getElementById(sid);
       const ele = document.getElementById(sid);
-      ele?.scrollIntoView();
+      if (ele !== null) {
+        ele.scrollIntoView({
+          behavior: "smooth",
+          block: "center",
+          inline: "nearest",
+        });
+      }
     }
     }
   }, [anchorInfo, initValue?.id, sid]);
   }, [anchorInfo, initValue?.id, sid]);