Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/icewind1991/files_markdown.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-09-04 16:17:14 +0300
committerRobin Appelman <robin@icewind.nl>2017-09-04 16:17:14 +0300
commit38fe1d747548ca83ef2d553c7fb7224e42a48031 (patch)
tree531a96b6be5dfefb9893bf033d1b96f747dc1be4 /js
parent9675f33ee46249832368af7aa7297a90c713d692 (diff)
cleaner table layout
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'js')
-rw-r--r--js/PreviewPlugin.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/js/PreviewPlugin.ts b/js/PreviewPlugin.ts
index a72a775..36324b3 100644
--- a/js/PreviewPlugin.ts
+++ b/js/PreviewPlugin.ts
@@ -9,6 +9,8 @@ declare const aceEditor: AceAjax.Editor;
type onPopstate = (this: Window, ev: PopStateEvent) => any;
+const scrollOffsetLines = 3;
+
export class PreviewPlugin {
private renderer: Renderer;
private Range: new (startRow: number, startColumn: number, endRow: number, endColumn: number) => AceAjax.Range;
@@ -98,7 +100,7 @@ export class PreviewPlugin {
return;
}
this.scrollMode = 'editor';
- const line = Math.floor(top / 15);
+ const line = Math.max(0, Math.floor(top / 15) - scrollOffsetLines);
const previewOffset = this.offsetMap.find((offset, index) => (typeof offset !== 'undefined') && index >= line);
if (typeof previewOffset !== 'undefined') {
$('#preview').scrollTop(previewOffset);
@@ -115,7 +117,7 @@ export class PreviewPlugin {
this.scrollMode = 'preview';
const top = this.previewElement.scrollTop() as number;
const previewLine = this.offsetMap.findIndex(offset => offset >= (top - 1));
- aceEditor.scrollToLine(previewLine, false, true, () => {
+ aceEditor.scrollToLine(Math.max(previewLine - scrollOffsetLines, 0), false, true, () => {
});
setTimeout(() => {
this.scrollMode = null;