Skip to content

Commit

Permalink
Take into account scrolling for dropCursor (#22)
Browse files Browse the repository at this point in the history
FIX: Fixes drop cursor positioning when the document is scrolled.
  • Loading branch information
lishid authored Dec 15, 2021
1 parent 38f0d90 commit 942cd1e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dropcursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ const drawDropCursor = ViewPlugin.fromClass(class {
let rect = pos != null && this.view.coordsAtPos(pos)
if (!rect) return null
let outer = this.view.scrollDOM.getBoundingClientRect()
return {left: rect.left - outer.left, top: rect.top - outer.top, height: rect.bottom - rect.top}
return {
left: rect.left - outer.left + this.view.scrollDOM.scrollLeft,
top: rect.top - outer.top + this.view.scrollDOM.scrollTop,
height: rect.bottom - rect.top
}
}

drawCursor(pos: {left: number, top: number, height: number} | null) {
Expand Down

0 comments on commit 942cd1e

Please sign in to comment.