1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-03-06 15:36:49 +02:00

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