Skip to content

Commit

Permalink
FIX: sidebar scrollable in all schemes [21].
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-nginx authored Sep 28, 2017
1 parent 1a6e24c commit 22569da
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions source/js/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,19 @@ NexT.utils = NexT.$u = {
return contentVisibilityHeight;
},

getSidebarb2tHeight: function () {
//var sidebarb2tHeight = (CONFIG.sidebar.b2t) ? document.getElementsByClassName('back-to-top')[0].clientHeight : 0;
var sidebarb2tHeight = (CONFIG.sidebar.b2t) ? $('.back-to-top').height() : 0;
//var sidebarb2tHeight = (CONFIG.sidebar.b2t) ? 24 : 0;
return sidebarb2tHeight;
},

getSidebarSchemePadding: function () {
var sidebarb2tHeight = (CONFIG.sidebar.b2t) ? $('.back-to-top').height() : 0,
sidebarNavHeight = ($('.sidebar-nav').css('display') == 'block') ? $('.sidebar-nav').outerHeight(true) : 0,
var sidebarNavHeight = ($('.sidebar-nav').css('display') == 'block') ? $('.sidebar-nav').outerHeight(true) : 0,
sidebarInner = $('.sidebar-inner'),
sidebarPadding = sidebarInner.innerWidth() - sidebarInner.width(),
sidebarSchemePadding = this.isPisces() || this.isGemini() ?
((sidebarPadding * 2) + sidebarNavHeight + (CONFIG.sidebar.offset * 2) + sidebarb2tHeight) :
((sidebarPadding * 2) + sidebarNavHeight + (CONFIG.sidebar.offset * 2) + this.getSidebarb2tHeight()) :
((sidebarPadding * 2) + (sidebarNavHeight / 2));
return sidebarSchemePadding;
}
Expand All @@ -290,3 +296,39 @@ NexT.utils = NexT.$u = {
// return this.isPisces() || this.isGemini();
// }
};

$(document).ready(function () {

initSidebarDimension();

/**
* Init Sidebar & TOC inner dimensions on all pages and for all schemes.
* Need for Sidebar/TOC inner scrolling if content taller then viewport.
*/
function initSidebarDimension () {
var updateSidebarHeightTimer;

$(window).on('resize', function () {
updateSidebarHeightTimer && clearTimeout(updateSidebarHeightTimer);

updateSidebarHeightTimer = setTimeout(function () {
var sidebarWrapperHeight = document.body.clientHeight - NexT.utils.getSidebarSchemePadding();

updateSidebarHeight(sidebarWrapperHeight);
}, 0);
});

// Initialize Sidebar & TOC Height.
updateSidebarHeight(document.body.clientHeight - NexT.utils.getSidebarSchemePadding());

// Initialize Sidebar & TOC Width.
var scrollbarWidth = NexT.utils.getScrollbarWidth();
$('.site-overview, .post-toc').css('width', 'calc(100% + ' + scrollbarWidth + 'px)');
}

function updateSidebarHeight (height) {
height = height || 'auto';
$('.site-overview, .post-toc').css('max-height', height);
}

});

0 comments on commit 22569da

Please sign in to comment.