-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c663224
commit 4555372
Showing
1 changed file
with
9 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,14 @@ | ||
$(function() { | ||
var selector = '#usersuite-sidebar-nav'; | ||
var $toc = $(selector); | ||
var $parent = $toc.parent(); | ||
var offset = 60; | ||
var $body = $('body'); | ||
document.addEventListener("DOMContentLoaded", () => { | ||
const selector = '#usersuite-sidebar-nav'; | ||
const $toc = $(selector); | ||
const $parent = $toc.parent(); | ||
const offset = 60; | ||
const $body = $('body'); | ||
Toc.init($toc); | ||
$body.scrollspy({ | ||
target: selector, | ||
offset: offset | ||
}); | ||
$body.scrollspy({target: selector, offset: offset}); | ||
$toc.affix({ | ||
offset: { | ||
top: function() { | ||
return $parent.offset().top - offset; | ||
} | ||
} | ||
offset: {top: () => $parent.offset().top - offset} | ||
}); | ||
// Handle window resize | ||
$(window).resize(function(){ | ||
$toc.affix('checkPosition'); | ||
}); | ||
$(window).resize(() => $toc.affix('checkPosition')); | ||
}); |