|
@@ -49,7 +49,8 @@ export default class PageEditor extends React.Component {
|
|
|
this.lastScrolledDateWithCursor = null;
|
|
this.lastScrolledDateWithCursor = null;
|
|
|
|
|
|
|
|
// create throttled function
|
|
// create throttled function
|
|
|
- this.scrollPreviewByLineWithThrottle = throttle(20, this.scrollPreviewByLine);
|
|
|
|
|
|
|
+ this.scrollPreviewByEditorScrollWithThrottle = throttle(20, this.scrollPreviewByEditorScroll);
|
|
|
|
|
+ this.scrollPreviewByCursorMovingWithThrottle = throttle(20, this.scrollPreviewByCursorMoving);
|
|
|
this.renderWithDebounce = debounce(50, throttle(100, this.renderPreview));
|
|
this.renderWithDebounce = debounce(50, throttle(100, this.renderPreview));
|
|
|
this.saveDraftWithDebounce = debounce(800, this.saveDraft);
|
|
this.saveDraftWithDebounce = debounce(800, this.saveDraft);
|
|
|
}
|
|
}
|
|
@@ -197,24 +198,30 @@ export default class PageEditor extends React.Component {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.scrollPreviewByLineWithThrottle(data.line);
|
|
|
|
|
|
|
+ this.scrollPreviewByEditorScrollWithThrottle(data.line);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onEditorScrollCursorIntoView(line) {
|
|
onEditorScrollCursorIntoView(line) {
|
|
|
this.lastScrolledDateWithCursor = new Date();
|
|
this.lastScrolledDateWithCursor = new Date();
|
|
|
- this.scrollPreviewByLineWithThrottle(line);
|
|
|
|
|
|
|
+ this.scrollPreviewByCursorMovingWithThrottle(line);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* scroll Preview by the specified line
|
|
* scroll Preview by the specified line
|
|
|
* @param {number} line
|
|
* @param {number} line
|
|
|
*/
|
|
*/
|
|
|
- scrollPreviewByLine(line) {
|
|
|
|
|
|
|
+ scrollPreviewByEditorScroll(line) {
|
|
|
if (this.previewElement == null) {
|
|
if (this.previewElement == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
scrollSyncHelper.scrollToRevealSourceLine(this.previewElement, line);
|
|
scrollSyncHelper.scrollToRevealSourceLine(this.previewElement, line);
|
|
|
};
|
|
};
|
|
|
|
|
+ scrollPreviewByCursorMoving(line) {
|
|
|
|
|
+ if (this.previewElement == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ scrollSyncHelper.scrollToRevealOverflowingSourceLine(this.previewElement, line);
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
|
* methods for draft
|
|
* methods for draft
|