Skip to content

Commit

Permalink
Take canvas offsets into account when dropping a new block on the can…
Browse files Browse the repository at this point in the history
…vas. (#4387)

Take canvas offsets into account when dropping a new block on the canvas. Relates to #2824

Co-authored-by: Artur Arseniev <[email protected]>
  • Loading branch information
contentfree and artf authored Jun 18, 2022
1 parent ac22ab6 commit 6712e58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/utils/Droppable.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ export default class Droppable {
let comp;
if (!cancelled) {
comp = wrapper.append(content)[0];
const { left, top, position } = target.getStyle();
comp.addStyle({ left, top, position });
const canvasOffset = editor.Canvas.getOffset();
const { top, left, position } = target.getStyle();
comp.addStyle({
left: parseFloat(left) - canvasOffset.left + 'px',
top: parseFloat(top) - canvasOffset.top + 'px',
position,
});
}
this.handleDragEnd(comp, dt);
target.remove();
Expand Down

0 comments on commit 6712e58

Please sign in to comment.