1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/utils/useScrollUtils.ts

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));
});
}