mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
help: Fix links with query selector from left sidebar.
This resolves the issue of scrolling to correct position when loaded from left sidebar to a link with query selector. Fixes #6714.
This commit is contained in:
parent
ced9cba5ff
commit
d48664fc5f
@ -69,6 +69,15 @@ function render_code_sections() {
|
||||
}
|
||||
}
|
||||
|
||||
function scrollToHash(container) {
|
||||
var hash = window.location.hash;
|
||||
if (hash !== '') {
|
||||
container.scrollTop = $(hash).position().top - $('.markdown .content').position().top;
|
||||
} else {
|
||||
container.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
|
||||
(function () {
|
||||
var html_map = {};
|
||||
var loading = {
|
||||
@ -117,6 +126,7 @@ function render_code_sections() {
|
||||
$(".markdown .content").html(html_map[path]);
|
||||
Ps.update(container);
|
||||
render_code_sections();
|
||||
scrollToHash(container);
|
||||
} else {
|
||||
loading.name = path;
|
||||
|
||||
@ -125,10 +135,10 @@ function render_code_sections() {
|
||||
$(".markdown .content").html(html_map[path]);
|
||||
loading.name = null;
|
||||
Ps.update(container);
|
||||
scrollToHash(container);
|
||||
});
|
||||
}
|
||||
|
||||
container.scrollTop = 0;
|
||||
$(".sidebar").removeClass("show");
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user