]> BookStack Code Mirror - bookstack/commitdiff
Updated sidebar to prevent rubber-banding with comments disabled
authorDan Brown <redacted>
Sat, 19 Jan 2019 11:10:46 +0000 (11:10 +0000)
committerDan Brown <redacted>
Sat, 19 Jan 2019 11:10:46 +0000 (11:10 +0000)
Fixes #1218

resources/assets/js/components/page-display.js

index cbb672222c264cc1ab5114269771989f9f1aa9aa..bca641cb6161e65e77b10bf81630bfe95c24e359 100644 (file)
@@ -123,20 +123,21 @@ class PageDisplay {
 
     setupStickySidebar() {
         // Make the sidebar stick in view on scroll
-        let $window = $(window);
-        let $sidebar = $("#sidebar .scroll-body");
-        let $bookTreeParent = $sidebar.parent();
+        const $window = $(window);
+        const $sidebar = $("#sidebar .scroll-body");
+        const $sidebarContainer = $sidebar.parent();
+        const sidebarHeight = $sidebar.height() + 32;
 
         // Check the page is scrollable and the content is taller than the tree
-        let pageScrollable = ($(document).height() > ($window.height() + 40)) && ($sidebar.height() < $('.page-content').height());
+        const pageScrollable = ($(document).height() > ($window.height() + 40)) && (sidebarHeight < $('.page-content').height());
 
         // Get current tree's width and header height
-        let headerHeight = $("#header").height() + $(".toolbar").height();
+        const headerHeight = $("#header").height() + $(".toolbar").height();
         let isFixed = $window.scrollTop() > headerHeight;
 
         // Fix the tree as a sidebar
         function stickTree() {
-            $sidebar.width($bookTreeParent.width() + 15);
+            $sidebar.width($sidebarContainer.width() + 15);
             $sidebar.addClass("fixed");
             isFixed = true;
         }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.