blob: 99f9c101fe782906590883202c60c70356e4440f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/**
* Copyright (c) 2016 Weitian LI <liweitianux@live.com>
* MIT license
*
* JavaScript codes for the Web UI of "fg21sim"
*/
"use strict";
$(document).ready(function () {
/**
* Offset the page to adjust for the fixed navigation banner
*/
var nav_height = $("nav.navigation").outerHeight();
var scroll_target = function () {
if ($(":target").length) {
var offset = $(":target").offset();
var scroll_to = offset.top - nav_height * 1.2;
$("html, body").animate({scrollTop: scroll_to}, 0);
}
};
$(window).on("hashchange", scroll_target);
/* FIXME: This seems not work ... */
if (window.location.hash) {
scroll_target();
}
});
|