Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix: clean up dragimg nodes after dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Apr 26, 2018
1 parent ed39ced commit 70d4708
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/component/container/element-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const DRAG_IMG_STYLE = `

@observer
export class ElementList extends React.Component<{}, ElementListState> {
private dragImg?: HTMLElement;

public state = {
dragging: true
};
Expand Down Expand Up @@ -241,6 +243,10 @@ export class ElementList extends React.Component<{}, ElementListState> {

private handleDragEnd(e: React.DragEvent<HTMLElement>): void {
this.setState({ dragging: false });

if (this.dragImg && this.dragImg.parentNode) {
this.dragImg.parentNode.removeChild(this.dragImg);
}
}

private handleDragStart(e: React.DragEvent<HTMLElement>): void {
Expand All @@ -260,6 +266,7 @@ export class ElementList extends React.Component<{}, ElementListState> {
dragImg.setAttribute('style', DRAG_IMG_STYLE);
document.body.appendChild(dragImg);
e.dataTransfer.setDragImage(dragImg, 75, 15);
this.dragImg = dragImg;
}
}

Expand Down

0 comments on commit 70d4708

Please sign in to comment.