Skip to content

Commit

Permalink
fix: toc not active in Safari, close kitian616#84
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Aug 10, 2018
1 parent 1871481 commit 5056c80
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions _includes/scripts/lib/affix.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
_options.disabled !== undefined && (disabled = _options.disabled);
$scrollTarget = $(scrollTarget);
$scroller = $(scroller);
isOverallScroller = window.isOverallScroller($scroller[0]);
isOverallScroller = window.isOverallScroller($scrollTarget[0]);
$scroll = $(scroll);
calc(true);
}
function initData() {
top();
rootHeight = $root.outerHeight();
rootTop = $root.offset().top + (isOverallScroller ? 0 : $scroller.scrollTop());
rootTop = $root.offset().top + (isOverallScroller ? 0 : $scrollTarget.scrollTop());
rootLeft = $root.offset().left;
}
function calc(needInitData) {
Expand Down
2 changes: 1 addition & 1 deletion _includes/scripts/lib/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
});
}
function setState(element, disabled) {
var scrollTop = $scroller.scrollTop(), i;
var scrollTop = $scrollTarget.scrollTop(), i;
if (disabled || !headingsPos || headingsPos.length < 1) { return; }
if (element) {
$activeCur = element;
Expand Down
2 changes: 1 addition & 1 deletion _includes/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
};

window.isOverallScroller = function(node) {
return node === document.documentElement || node === document.body;
return node === document.documentElement || node === document.body || node === window;
};

window.pageLoad = (function () {
Expand Down

0 comments on commit 5056c80

Please sign in to comment.