mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Updated sidebar to prevent rubber-banding with comments disabled
Fixes #1218
This commit is contained in:
parent
a3ccde8698
commit
156c0a88e9
@ -123,20 +123,21 @@ class PageDisplay {
|
|||||||
|
|
||||||
setupStickySidebar() {
|
setupStickySidebar() {
|
||||||
// Make the sidebar stick in view on scroll
|
// Make the sidebar stick in view on scroll
|
||||||
let $window = $(window);
|
const $window = $(window);
|
||||||
let $sidebar = $("#sidebar .scroll-body");
|
const $sidebar = $("#sidebar .scroll-body");
|
||||||
let $bookTreeParent = $sidebar.parent();
|
const $sidebarContainer = $sidebar.parent();
|
||||||
|
const sidebarHeight = $sidebar.height() + 32;
|
||||||
|
|
||||||
// Check the page is scrollable and the content is taller than the tree
|
// 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
|
// 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;
|
let isFixed = $window.scrollTop() > headerHeight;
|
||||||
|
|
||||||
// Fix the tree as a sidebar
|
// Fix the tree as a sidebar
|
||||||
function stickTree() {
|
function stickTree() {
|
||||||
$sidebar.width($bookTreeParent.width() + 15);
|
$sidebar.width($sidebarContainer.width() + 15);
|
||||||
$sidebar.addClass("fixed");
|
$sidebar.addClass("fixed");
|
||||||
isFixed = true;
|
isFixed = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user