Skip to content

Commit dfcc6be

Browse files
committed
fix: Incorrect scroll offset in the docs API section and inner pages with breadcrumbs
1 parent b302937 commit dfcc6be

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

_assets/js/toc-base.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
function animateScrolling(hash) {
2+
var isApiSection = $("article.api-reference").length == 1;
3+
var hasBreadCrumbs = $("p.breadcrumbs").length == 1 && $("p.breadcrumbs").text().trim() != "";
24
var currentScrollTop = $(window).scrollTop();
35
var offset = $(hash).offset() || { top: currentScrollTop };
4-
var scrollOffsetCorrection = currentScrollTop == 0 ? HEADER_HEIGHT + NAVBAR_HEIGHT : NAVBAR_HEIGHT;
6+
7+
var scrollOffsetCorrection = NAVBAR_HEIGHT;
8+
if (currentScrollTop == 0) {
9+
scrollOffsetCorrection += HEADER_HEIGHT;
10+
if (hasBreadCrumbs) {
11+
scrollOffsetCorrection += BREADCRUMBS_HEIGHT;
12+
}
13+
if (isApiSection) {
14+
scrollOffsetCorrection += API_SCROLL_FIX;
15+
}
16+
}
517

618
$('html, body').animate({
719
scrollTop: offset.top - scrollOffsetCorrection

_assets/js/top-menu.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var HEADER_HEIGHT = 81;
22
var TELERIKBAR_HEIGHT = 70;
33
var NAVBAR_HEIGHT = 76;
4+
var BREADCRUMBS_HEIGHT = 20;
5+
var API_SCROLL_FIX = 40;
46
var SCROLLSPY_OFFSET = TELERIKBAR_HEIGHT + 10; // 10 compensates for the space above the anchored heading
57
var FOOTER_DISTANCE = 20;
68
var windowHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);

0 commit comments

Comments
 (0)