mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-22 00:48:25 +00:00
Adjust scroll behavior in review panel to account for wrapped lines (#24029)
GitOrigin-RevId: 748f7ffcdd2d0c83132b43de99b10f598227f6b0
This commit is contained in:
parent
42ee56ecd4
commit
08882c63df
1 changed files with 12 additions and 1 deletions
|
@ -94,9 +94,20 @@ export const ReviewPanelEntry: FC<{
|
|||
|
||||
// scroll to line (centered)
|
||||
const blockInfo = view.lineBlockAt(position)
|
||||
const coordsAtPos = view.coordsAtPos(position)
|
||||
const coordsAtLineStart = view.coordsAtPos(blockInfo.from)
|
||||
let wrappedLineOffset = 0
|
||||
if (coordsAtPos !== null && coordsAtLineStart !== null) {
|
||||
wrappedLineOffset = coordsAtPos.top - coordsAtLineStart.top
|
||||
}
|
||||
|
||||
const editorHeight = view.scrollDOM.getBoundingClientRect().height
|
||||
view.scrollDOM.scrollTo({
|
||||
top: blockInfo.top - editorHeight / 2 + blockInfo.height,
|
||||
top:
|
||||
blockInfo.top -
|
||||
editorHeight / 2 +
|
||||
view.defaultLineHeight +
|
||||
wrappedLineOffset,
|
||||
behavior: 'smooth',
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue