Skip to content

Commit

Permalink
Improve usersuite scrollspy JS
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjuhrich committed Oct 7, 2023
1 parent c663224 commit 4555372
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions sipa/static/js/usersuite_index.js
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'));
});

0 comments on commit 4555372

Please sign in to comment.