From ac7c23aa3d494a296b1bbbf3ebbbf4335b2cddc8 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Sun, 30 Sep 2018 15:30:41 +0200 Subject: [PATCH] Fixed & Optimized for #426. We are stars? =) --- source/js/src/schemes/pisces.js | 39 ++++++++++----------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/source/js/src/schemes/pisces.js b/source/js/src/schemes/pisces.js index 015581cc91..077a4d5950 100644 --- a/source/js/src/schemes/pisces.js +++ b/source/js/src/schemes/pisces.js @@ -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'); - });