Skip to content

Commit

Permalink
Updated sidebar to prevent rubber-banding with comments disabled
Browse files Browse the repository at this point in the history
Fixes #1218
  • Loading branch information
ssddanbrown committed Jan 19, 2019
1 parent a3ccde8 commit 156c0a8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions resources/assets/js/components/page-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 156c0a8

Please sign in to comment.