From 4e2ad5766b3f32965fa0d296055d46080ffb4b78 Mon Sep 17 00:00:00 2001 From: benweet Date: Tue, 19 Nov 2013 23:44:31 +0000 Subject: [PATCH] Fixed first section in scroll link extension --- public/res/extensions/scrollLink.js | 17 ++++++++++------- public/res/html/bodyIndex.html | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/public/res/extensions/scrollLink.js b/public/res/extensions/scrollLink.js index 6666186a..39921196 100644 --- a/public/res/extensions/scrollLink.js +++ b/public/res/extensions/scrollLink.js @@ -54,16 +54,19 @@ define([ var htmlSectionOffset; var previewScrollTop = $previewElt.scrollTop(); $previewElt.find(".preview-content > .se-section-delimiter").each(function() { + if(htmlSectionOffset === undefined) { + // Force start to 0 for the first section + htmlSectionOffset = 0; + return; + } var $delimiterElt = $(this); // Consider div scroll position var newSectionOffset = $delimiterElt.position().top + previewScrollTop; - if(htmlSectionOffset !== undefined) { - htmlSectionList.push({ - startOffset: htmlSectionOffset, - endOffset: newSectionOffset, - height: newSectionOffset - htmlSectionOffset - }); - } + htmlSectionList.push({ + startOffset: htmlSectionOffset, + endOffset: newSectionOffset, + height: newSectionOffset - htmlSectionOffset + }); htmlSectionOffset = newSectionOffset; }); // Last section diff --git a/public/res/html/bodyIndex.html b/public/res/html/bodyIndex.html index bc3bf32a..cbb4e232 100644 --- a/public/res/html/bodyIndex.html +++ b/public/res/html/bodyIndex.html @@ -298,7 +298,7 @@
- px