Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: including the canvas offset in the onDrop event in the canvas wrapper... #34

Merged
merged 1 commit into from
Aug 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/components/Canvas/Canvas.wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ export class CanvasWrapper extends React.Component<ICanvasWrapperProps, IState>
onDeleteKey,
onCanvasDrop,
} = this.props

const {
offsetX,
offsetY,
} = this.state
return (
<CanvasContext.Provider value={{ offsetX: this.state.offsetX, offsetY: this.state.offsetY }}>
<ComponentOuter ref={this.ref}>
Expand All @@ -91,8 +94,8 @@ export class CanvasWrapper extends React.Component<ICanvasWrapperProps, IState>
onDrop={ (e) => {
const data = JSON.parse(e.dataTransfer.getData(REACT_FLOW_CHART))
onCanvasDrop({ data, position: {
x: e.clientX - position.x,
y: e.clientY - position.y,
x: e.clientX - (position.x + offsetX),
y: e.clientY - (position.y + offsetY),
}})
} }
onDragOver={(e) => e.preventDefault()}
Expand Down