Verified Commit eddec38f authored by Camil Staps's avatar Camil Staps 🚀

Center-ish line in library browser (resolves #107)

parent cb6b9f2c
......@@ -9,6 +9,11 @@ var curmod = null;
var refresh_on_hash = true;
var line = null;
Element.prototype.documentOffsetTop = function() {
return this.offsetTop +
(this.offsetParent ? this.offsetParent.documentOffsetTop() : 0);
};
function loadModule(elem) {
if (typeof elem != 'undefined') {
line = null;
......@@ -36,8 +41,11 @@ function loadModule(elem) {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
viewer.innerHTML = xmlHttp.response;
if (line != null)
document.getElementById('line-' + line).scrollIntoView(true);
if (line != null) {
var l = document.getElementById('line-' + line).documentOffsetTop();
console.log(l);
document.getElementById('viewer').scrollTo(0, l - window.innerHeight/4);
}
var linenos = document.getElementsByClassName('special');
for (var i = 0; i < linenos.length; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment