Skip to content

Commit

Permalink
fix: subtract draggingContainer offset when position
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector committed Oct 5, 2023
1 parent e58a0cc commit 54436b0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/x6-plugin-dnd/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,18 @@ export class Dnd extends View implements Graph.Plugin {
}

if (this.draggingGraph) {
Dom.css(this.container, {
left: `${offset.left}px`,
top: `${offset.top}px`,
})
if (this.options.draggingContainer) {
const { top, left } = Dom.offset(this.options.draggingContainer)
Dom.css(this.container, {
left: `${offset.left - left}px`,
top: `${offset.top - top}px`,
})
} else {
Dom.css(this.container, {
left: `${offset.left}px`,
top: `${offset.top}px`,
})
}
}

return offset
Expand Down

0 comments on commit 54436b0

Please sign in to comment.