Don't sync scroll when input is not scrollable.

https://meta.discourse.org/t/composer-preview-scroll-not-syncing-with-editor/74975/14?u=tgxworld
This commit is contained in:
Guo Xiang Tan 2017-12-01 17:07:28 +08:00
parent 1376a86bcc
commit 2e860eddc1
1 changed files with 5 additions and 1 deletions

View File

@ -254,8 +254,12 @@ export default Ember.Component.extend({
_syncEditorAndPreviewScroll($input, $preview, scrollMap) {
let scrollTop;
const inputHeight = $input.height();
const inputScrollHeight = $input[0].scrollHeight;
const inputClientHeight = $input[0].clientHeight;
const scrollable = inputScrollHeight > inputClientHeight;
if (($input.height() + $input.scrollTop() + 100) > $input[0].scrollHeight) {
if (scrollable && ((inputHeight + $input.scrollTop() + 100) > inputScrollHeight)) {
scrollTop = $preview[0].scrollHeight;
} else {
const lineHeight = parseFloat($input.css('line-height'));