Skip to content

Commit

Permalink
Merge pull request #431 from theme-next/dev
Browse files Browse the repository at this point in the history
Fixed & Optimized for #426.
  • Loading branch information
ivan-nginx authored Sep 30, 2018
2 parents 8d4f34e + 891f618 commit a54ec63
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions source/js/src/schemes/pisces.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,48 +16,31 @@ $(document).ready(function() {
return footerOffset;
}

function setSidebarMarginTop(headerOffset) {
return $('#sidebar').css({ 'margin-top': headerOffset });
}

function initAffix() {
var headerOffset = getHeaderOffset();
var footerOffset = getFooterOffset();
var sidebarHeight = $('#sidebar').height() + NexT.utils.getSidebarb2tHeight();
var contentHeight = $('#content').height();

// Not affix if sidebar taller then content (to prevent bottom jumping).
if (headerOffset + sidebarHeight < contentHeight) {
sidebarInner.affix({
offset: {
top : headerOffset - sidebarOffset,
bottom: footerOffset
}
});
}

setSidebarMarginTop(headerOffset).css({ 'margin-left': 'initial' });
}

/* function recalculateAffixPosition() {
$(window).off('.affix');
sidebarInner.removeData('bs.affix').removeClass('affix affix-top affix-bottom');
initAffix();
} */
sidebarInner.affix({
offset: {
top : headerOffset - sidebarOffset,
bottom: footerOffset
}
});

$('#sidebar').css({ 'margin-left': 'initial', 'margin-top': headerOffset });
sidebarInner.affix('checkPosition');
}

function resizeListener() {
var mql = window.matchMedia('(min-width: 991px)');
mql.addListener(function(e) {
if (e.matches) {
//recalculateAffixPosition();
sidebarInner.affix('checkPosition');
initAffix();
}
});
}

initAffix();
resizeListener();
// Fixed wrong top alignment if page scrolled to the bottom after cleared cache and browser refresh.
sidebarInner.affix('checkPosition');

});

0 comments on commit a54ec63

Please sign in to comment.