Files
joplin/ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/utils/useScrollUtils.ts
T

13 lines
434 B
TypeScript

// Helper functions to sync up scrolling
export default function useScrollUtils(CodeMirror: any) {
CodeMirror.defineExtension('getScrollPercent', function() {
const info = this.getScrollInfo();
return info.top / (info.height - info.clientHeight);
});
CodeMirror.defineExtension('setScrollPercent', function(p: number) {
const info = this.getScrollInfo();
this.scrollTo(null, p * (info.height - info.clientHeight));
});
}