mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-20 10:15:17 -04: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) {
|
if (!editor || !onScroll || !editorScroll) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const scrollEventValue = editorScroll.top as number
|
const line = editor.lineAtHeight(editorScroll.top, 'local')
|
||||||
const line = editor.lineAtHeight(scrollEventValue, 'local')
|
|
||||||
const startYOfLine = editor.heightAtLine(line, 'local')
|
const startYOfLine = editor.heightAtLine(line, 'local')
|
||||||
const lineInfo = editor.lineInfo(line)
|
const lineInfo = editor.lineInfo(line)
|
||||||
if (lineInfo === null) {
|
if (lineInfo === null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const heightOfLine = (lineInfo.handle as { height: number }).height
|
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 percentage = Math.floor(percentageRaw * 100)
|
||||||
|
|
||||||
const newScrollState: ScrollState = { firstLineInView: line + 1, scrolledPercentage: percentage }
|
const newScrollState: ScrollState = { firstLineInView: line + 1, scrolledPercentage: percentage }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue