Browse Source

fixes abpframework/abp#678 . Added JQuery scroll for hashed URL.

Locating to a lazy loading html element invalidates to hash scrolling from the URL. Added cross-browser JQuery solution that animates to the given element with ID or Name.
pull/696/head
Alper Ebicoglu 8 years ago
parent
commit
1f583ce960
  1. 36
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/Scripts/vs.js

36
modules/docs/src/Volo.Docs.Web/Pages/Documents/Shared/Scripts/vs.js

@ -34,11 +34,34 @@
return false;
});
var scrollToHashLink = function () {
var hash = window.location.hash;
if (!hash || hash === "#") {
return;
}
var $targetElement = $(hash);
$targetElement = $targetElement.length ? $targetElement : $('[name=' + this.hash.slice(1) + ']');
if (!$targetElement.length) {
return;
}
$('html,body').stop().animate({
scrollTop: $targetElement.offset().top
}, 200);
return;
};
$(document).ready(function () {
handleCustomScrolls();
var $myNav = $("#docs-sticky-index");
Toc.init($myNav);
$("body").scrollspy({
target: $myNav
});
@ -59,6 +82,7 @@
$(".toggle-row").slideToggle(400);
$(this).toggleClass("less");
});
$(".close-mmenu").on("click", function () {
$(".navbar-collapse").removeClass("show");
});
@ -66,7 +90,10 @@
$(".open-dmenu").on("click", function () {
$(".docs-tree-list").slideToggle();
});
scrollToHashLink();
});
$(window).resize(function () {
handleCustomScrolls();
});
@ -74,7 +101,7 @@
function handleCustomScrolls() {
var wWidth = $(window).width();
if (wWidth > 766) {
if (wWidth > 766) {
$("#sidebar-scroll").mCustomScrollbar({
theme: "minimal"
});
@ -82,13 +109,9 @@
$("#scroll-index").mCustomScrollbar({
theme: "minimal-dark"
});
//$(".docs-text-field").mCustomScrollbar({
// axis: "xy",
// theme: "minimal"
//});
}
}
window.Toc.helpers.createNavList = function () {
return $('<ul class="nav nav-pills flex-column"></ul>');
};
@ -107,4 +130,5 @@
$li.append($a);
return $li;
};
})(jQuery);
Loading…
Cancel
Save