فهرست منبع

定位位置控制

laiguoran 4 سال پیش
والد
کامیت
1abd4d22fb
1فایلهای تغییر یافته به همراه17 افزوده شده و 2 حذف شده
  1. 17 2
      app/view/stage/audit_modal.ejs

+ 17 - 2
app/view/stage/audit_modal.ejs

@@ -1595,10 +1595,25 @@
     });
     $('.modal').on('shown.bs.modal', function () {
         const height = $(this)[0].scrollHeight
-        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]')
+        const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
+        const hdheight = hdiv ? hdiv.parents('.list-group-item').offset().top : 0;
+        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
+        const bdiv = scrollBox.offset().top;
         // 450是modal没有滚动条时的最大高度,超过则出现滚动条,需要自动下拉到底部
-        if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
+        // if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
+        //     scrollBox.scrollTop(height);
+        // }
+        if (hdiv && hdheight - bdiv > 300) {
+            scrollBox.scrollTop(hdheight - bdiv);
+        } else if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
             scrollBox.scrollTop(height);
         }
     });
+
+    function divSearch(div) {
+        if (div.length > 0) {
+            return true;
+        }
+        return false;
+    }
 </script>