Sticky meta tabs (TOC etc.)
This commit is contained in:
parent
7d0d2234e5
commit
a0b1eecca4
2 changed files with 31 additions and 2 deletions
|
@ -64,11 +64,27 @@
|
|||
};
|
||||
|
||||
|
||||
var stickyBox = function ($metaBox, topOffset, leftOffset) {
|
||||
if (window.pageYOffset >= topOffset) {
|
||||
$metaBox.addClass("sticky").attr("style", "left: " + leftOffset + "px");
|
||||
} else {
|
||||
$metaBox.removeClass("sticky").removeAttr("style");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$(function(){
|
||||
var $metaBox = $('#spr__meta-box');
|
||||
if (!$metaBox.length) return;
|
||||
|
||||
registerClickForTabsInMetaBox($metaBox);
|
||||
|
||||
var topOffset = $metaBox.offset().top;
|
||||
window.onscroll = function () {
|
||||
// check while scrolling, or window resizing will break horizontal positioning
|
||||
var leftOffset = $metaBox.offset().left;
|
||||
stickyBox($metaBox, topOffset, leftOffset)
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue