mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Editor and preview does not sync when scrolled to the bottom.
This commit is contained in:
parent
bb0b7b61d7
commit
4816619ba3
@ -254,22 +254,33 @@ export default Ember.Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_syncEditorAndPreviewScroll($input, $preview, scrollMap) {
|
_syncEditorAndPreviewScroll($input, $preview, scrollMap) {
|
||||||
|
let scrollTop;
|
||||||
|
|
||||||
|
if (($input.height() + $input.scrollTop() + 100) > $input[0].scrollHeight) {
|
||||||
|
scrollTop = $preview[0].scrollHeight;
|
||||||
|
} else {
|
||||||
const lineHeight = parseFloat($input.css('line-height'));
|
const lineHeight = parseFloat($input.css('line-height'));
|
||||||
const lineNumber = Math.floor($input.scrollTop() / lineHeight);
|
const lineNumber = Math.floor($input.scrollTop() / lineHeight);
|
||||||
|
scrollTop = scrollMap[lineNumber];
|
||||||
|
}
|
||||||
|
|
||||||
$preview.stop(true).animate({
|
$preview.stop(true).animate({ scrollTop }, 100, 'linear');
|
||||||
scrollTop: scrollMap[lineNumber]
|
|
||||||
}, 100, 'linear');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_syncPreviewAndEditorScroll($input, $preview, scrollMap) {
|
_syncPreviewAndEditorScroll($input, $preview, scrollMap) {
|
||||||
if (scrollMap.length < 1) return;
|
if (scrollMap.length < 1) return;
|
||||||
const scrollTop = $preview.scrollTop();
|
|
||||||
const lineHeight = parseFloat($input.css('line-height'));
|
|
||||||
|
|
||||||
$input.stop(true).animate({
|
let scrollTop;
|
||||||
scrollTop: lineHeight * scrollMap.findIndex(offset => offset > scrollTop)
|
const previewScrollTop = $preview.scrollTop();
|
||||||
}, 100, 'linear');
|
|
||||||
|
if (($preview.height() + previewScrollTop + 100) > $preview[0].scrollHeight) {
|
||||||
|
scrollTop = $input[0].scrollHeight;
|
||||||
|
} else {
|
||||||
|
const lineHeight = parseFloat($input.css('line-height'));
|
||||||
|
scrollTop = lineHeight * scrollMap.findIndex(offset => offset > previewScrollTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
$input.stop(true).animate({ scrollTop }, 100, 'linear');
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderUnseenMentions($preview, unseen) {
|
_renderUnseenMentions($preview, unseen) {
|
||||||
|
Loading…
Reference in New Issue
Block a user