Browse Source

Segment click scroll perfection

Vijayakrishnan 3 years ago
parent
commit
f1e7883a6a
1 changed files with 4 additions and 5 deletions
  1. 4 5
      resources/views/app/patient/note/dashboard_script.blade.php

+ 4 - 5
resources/views/app/patient/note/dashboard_script.blade.php

@@ -210,13 +210,12 @@
                         }
                         else {
                             let docRoot = $('html');
-                            let prevSectionTop = editParent.offset().top;
+                            let prevEffectiveTop = editParent.offset().top - docRoot.scrollTop();
                             $('.note-section.edit').removeClass('edit');
                             editParent.addClass('edit');
-                            let newSectionTop = editParent.offset().top;
-                            // console.log(prevSectionTop, newSectionTop);
-                            if(newSectionTop < prevSectionTop) {
-                                docRoot.scrollTop(docRoot.scrollTop() - (prevSectionTop - newSectionTop));
+                            let newEffectiveTop = editParent.offset().top - docRoot.scrollTop();
+                            if(newEffectiveTop < prevEffectiveTop) {
+                                docRoot.scrollTop(docRoot.scrollTop() - (prevEffectiveTop - newEffectiveTop));
                             }
                         }