mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-10 10:18:24 +00:00
Remove unnecessary assertion
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
22bade82a6
commit
9a62f27303
1 changed files with 2 additions and 3 deletions
|
@ -105,15 +105,14 @@ export const EditorPane: React.FC<EditorPaneProps & ScrollProps> = ({ onContentC
|
|||
if (!editor || !onScroll || !editorScroll) {
|
||||
return
|
||||
}
|
||||
const scrollEventValue = editorScroll.top as number
|
||||
const line = editor.lineAtHeight(scrollEventValue, 'local')
|
||||
const line = editor.lineAtHeight(editorScroll.top, 'local')
|
||||
const startYOfLine = editor.heightAtLine(line, 'local')
|
||||
const lineInfo = editor.lineInfo(line)
|
||||
if (lineInfo === null) {
|
||||
return
|
||||
}
|
||||
const heightOfLine = (lineInfo.handle as { height: number }).height
|
||||
const percentageRaw = (Math.max(scrollEventValue - startYOfLine, 0)) / heightOfLine
|
||||
const percentageRaw = (Math.max(editorScroll.top - startYOfLine, 0)) / heightOfLine
|
||||
const percentage = Math.floor(percentageRaw * 100)
|
||||
|
||||
const newScrollState: ScrollState = { firstLineInView: line + 1, scrolledPercentage: percentage }
|
||||
|
|
Loading…
Add table
Reference in a new issue