Skip to content

Commit

Permalink
improve scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
ain-soph committed Oct 19, 2021
1 parent 9a60cf7 commit 1eb2be5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
7 changes: 1 addition & 6 deletions js/side-menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ window.sideMenus = {
next.style.display = 'block';
link.attr('aria-expanded', 'true')
}
ev.stopPropagation()
ev.stopPropagation();
return false;
});
link.prepend(expand);
Expand Down Expand Up @@ -89,11 +89,6 @@ window.sideMenus = {
sideMenus.expandClosestUnexpandedParentList(linkWithHash);
}

// Bind click events on right menu links
$('#sphinx-template-right-menu').on('click', 'a.reference.internal', function() {
$(this).children("button").trigger("click");
});

sideMenus.handleNavBar();
sideMenus.handleLeftMenu();
if (sideMenus.rightMenuIsOnScreen()) {
Expand Down
9 changes: 6 additions & 3 deletions js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,17 @@ $(".stars-outer > i").on("click", function() {
})

$("#sphinx-template-side-scroll-right").on("click", "a.reference.internal", function (e) {
var href = $(this).attr("href").replaceAll('.', '\\.');
var link = $(this)
var href = link.attr("href").replaceAll('.', '\\.');
var offset = 0
if (href !== "#"){
offset = $(href).offset().top - utilities.getFixedOffset()
}
$('html, body').stop().animate({scrollTop: offset}, 850);
$('html').stop().animate({scrollTop: offset}, 850, function (){
link.children("button").trigger("click");
});
e.preventDefault();
// e.stopPropagation();
e.stopPropagation();
});

topMenu = $("#sphinx-template-side-scroll-right"),
Expand Down
16 changes: 7 additions & 9 deletions trojanzoo_sphinx_theme/static/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ window.sideMenus = {
next.style.display = 'block';
link.attr('aria-expanded', 'true')
}
ev.stopPropagation()
ev.stopPropagation();
return false;
});
link.prepend(expand);
Expand Down Expand Up @@ -505,11 +505,6 @@ window.sideMenus = {
sideMenus.expandClosestUnexpandedParentList(linkWithHash);
}

// Bind click events on right menu links
$('#sphinx-template-right-menu').on('click', 'a.reference.internal', function() {
$(this).children("button").trigger("click");
});

sideMenus.handleNavBar();
sideMenus.handleLeftMenu();
if (sideMenus.rightMenuIsOnScreen()) {
Expand Down Expand Up @@ -978,14 +973,17 @@ $(".stars-outer > i").on("click", function() {
})

$("#sphinx-template-side-scroll-right").on("click", "a.reference.internal", function (e) {
var href = $(this).attr("href").replaceAll('.', '\\.');
var link = $(this)
var href = link.attr("href").replaceAll('.', '\\.');
var offset = 0
if (href !== "#"){
offset = $(href).offset().top - utilities.getFixedOffset()
}
$('html, body').stop().animate({scrollTop: offset}, 850);
$('html').stop().animate({scrollTop: offset}, 850, function (){
link.children("button").trigger("click");
});
e.preventDefault();
// e.stopPropagation();
e.stopPropagation();
});

topMenu = $("#sphinx-template-side-scroll-right"),
Expand Down

0 comments on commit 1eb2be5

Please sign in to comment.