mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
12 lines
311 B
TypeScript
12 lines
311 B
TypeScript
|
import { EditorView } from '@codemirror/view';
|
||
|
|
||
|
|
||
|
const getScrollFraction = (view: EditorView) => {
|
||
|
const maxScroll = view.scrollDOM.scrollHeight - view.scrollDOM.clientHeight;
|
||
|
|
||
|
// Prevent division by zero
|
||
|
return maxScroll > 0 ? view.scrollDOM.scrollTop / maxScroll : 0;
|
||
|
};
|
||
|
|
||
|
export default getScrollFraction;
|