Merge pull request #4034 from novaugust/iss4027

Fix editor scroll depending on cursor location
This commit is contained in:
Paul Davis 2014-09-15 09:14:14 +01:00
commit d5ddbfee5a
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;
})
});