Skip to content

Commit 6e32f3e

Browse files
committed
Take canvas offsets into account when dropping a new block on the canvas. Relates to GrapesJS#2824
1 parent 8518e11 commit 6e32f3e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/utils/Droppable.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,13 @@ export default class Droppable {
112112
let comp;
113113
if (!cancelled) {
114114
comp = wrapper.append(content)[0];
115-
const { left, top, position } = target.getStyle();
116-
comp.addStyle({ left, top, position });
115+
const canvasOffset = editor.Canvas.getOffset();
116+
const { top, left, position } = target.getStyle();
117+
comp.addStyle({
118+
left: parseFloat(left) - canvasOffset.left + 'px',
119+
top: parseFloat(top) - canvasOffset.top + 'px',
120+
position,
121+
});
117122
}
118123
this.handleDragEnd(comp, dt);
119124
target.remove();

0 commit comments

Comments
 (0)