0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fix editor scroll depending on cursor location

Closes #4027
This commit is contained in:
Matt Enlow 2014-09-14 17:38:32 -06:00
parent 5c43b80cad
commit 986d3c1696
3 changed files with 11 additions and 14 deletions

View file

@ -212,7 +212,7 @@
}
.CodeMirror-lines {
padding: 65px 0 40px 0; /* Vertical padding around content */
padding-top: 65px; /* Vertical padding around content */
@media (max-width: 1000px) {padding-top: 25px;}
@media (max-width: 400px) {padding: 15px 0;}
}

View file

@ -98,8 +98,7 @@
.CodeMirror-scroll {
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px; margin-right: -30px;
padding-bottom: 30px; padding-right: 30px;
margin-right: -30px; padding-right: 30px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
@ -204,4 +203,4 @@
.CodeMirror div.CodeMirror-cursor {
visibility: hidden;
}
}
}

View file

@ -40,18 +40,16 @@ var EditorViewMixin = Ember.Mixin.create({
}
var scrollInfo = this.get('markdownScrollInfo'),
codemirror = scrollInfo.codemirror,
markdownHeight = scrollInfo.height - scrollInfo.clientHeight,
previewHeight = this.get('$previewContent').height() - this.get('$previewViewPort').height(),
ratio = previewHeight / markdownHeight,
previewPosition = scrollInfo.top * ratio,
isCursorAtEnd = codemirror.getCursor('end').line > codemirror.lineCount() - 5;
markdownHeight,
previewHeight,
ratio;
if (isCursorAtEnd) {
previewPosition = previewHeight + 30;
}
markdownHeight = scrollInfo.height - scrollInfo.clientHeight;
previewHeight = this.get('$previewContent').height() - this.get('$previewViewPort').height();
return previewPosition;
ratio = previewHeight / markdownHeight;
return scrollInfo.top * ratio;
})
});