修复两栏布局不能固定 #profile 的问题 (#320)

This commit is contained in:
ZNEIAT 2018-04-30 23:06:32 +08:00 committed by Ruipeng Zhang
parent 29235f6d3a
commit a4ef07b8c4
1 changed files with 55 additions and 48 deletions

View File

@ -43,23 +43,21 @@
e.stopPropagation(); e.stopPropagation();
}); });
// To Top & Fixed Profile // To Top
var sidebarElem = $('#sidebar'), var sidebarElem = $('#sidebar'),
toTopElem = $('#toTop'); toTopElem = $('#toTop');
if (sidebarElem.length) { (function () {
checkDisplayToTop(); if (!sidebarElem.length) return;
checkFixedProfile();
checkDisplayToTop();
$(document).on('scroll', function () { $(document).on('scroll', function () {
checkDisplayToTop(); checkDisplayToTop();
checkFixedProfile();
}); });
toTopElem.click(function () { toTopElem.click(function () {
$('body, html').animate({ scrollTop: 0 }, 600); $('body, html').animate({ scrollTop: 0 }, 600);
}); });
}
var isToTopDisplayed = false; var isToTopDisplayed = false;
function checkDisplayToTop() { function checkDisplayToTop() {
@ -83,6 +81,14 @@
toTopElem.css('right', 20); toTopElem.css('right', 20);
} }
} }
})();
// Fixed Profile
(function () {
checkFixedProfile();
$(document).on('scroll', function () {
checkFixedProfile();
});
var isFixedProfile = false; var isFixedProfile = false;
function checkFixedProfile() { function checkFixedProfile() {
@ -115,5 +121,6 @@
isFixedProfile = false; isFixedProfile = false;
} }
} }
})();
})(jQuery); })(jQuery);