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

Commit

Permalink
feat(component): add drag image styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tilman Frick committed Apr 23, 2018
1 parent 76ac1ae commit 71c298d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/component/container/element-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ export class ElementList extends React.Component {
onContextMenu: () => elementMenu(element),
handleDragStart: (e: React.DragEvent<HTMLElement>) => {
Store.getInstance().setDraggedElement(element);
e.dataTransfer.effectAllowed = 'move';

// restyle the drag image and move it somewhere invisible
var dragImg = e.currentTarget.querySelector('div').cloneNode(true);
dragImg.setAttribute(
'style',
'position: absolute; background-color: #fff; color: #000; padding: 1px 6px; border-radius: 3px; font-size: 12px; opacity: 1; top: 0; left: -500px;'
);
document.body.appendChild(dragImg);
e.dataTransfer.setDragImage(dragImg, 75, 10);
},
handleDragDropForChild: (e: React.DragEvent<HTMLElement>) => {
const patternId = e.dataTransfer.getData('patternId');
Expand Down
2 changes: 1 addition & 1 deletion src/lsg/patterns/element/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const Element: React.StatelessComponent<ElementProps> = props => {
active={active}
/>
)}
{title}
<div>{title}</div>
</StyledElementLabel>
{children && <StyledElementChild open={open}>{children}</StyledElementChild>}
</StyledElement>
Expand Down

0 comments on commit 71c298d

Please sign in to comment.