Browse Source

Take canvas offsets into account when dropping a new block on the canvas. (#4387)

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

Co-authored-by: Artur Arseniev <artur.catch@hotmail.it>
pull/4407/head
Dave Myron 4 years ago
committed by GitHub
parent
commit
6712e58f63
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/utils/Droppable.js

9
src/utils/Droppable.js

@ -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();

Loading…
Cancel
Save