Skip to content
Snippets Groups Projects
Commit a4c8f2ec authored by Dennis Collaris's avatar Dennis Collaris
Browse files

fix: ensure drag image is shown in all browsers

parent 6332043e
No related branches found
No related tags found
No related merge requests found
......@@ -56,8 +56,21 @@ export const Pill = React.memo((props: PillI) => {
clipPath: corner === 'diamond' ? 'polygon(0% 50%, 5% 0%, 95% 0%, 100% 50%, 95% 100%, 5% 100%)' : '',
};
const onDragStart = (event: React.DragEvent<HTMLDivElement>) => {
const pill = event.target as HTMLDivElement;
const dragImage = pill.cloneNode(true) as HTMLDivElement;
dragImage.style.transform = 'translate(0, 0)'; // Removes the background from drag image in Chrome
document.body.appendChild(dragImage);
event.dataTransfer.setDragImage(dragImage, pillWidth / 2, pillHeight / 2);
setTimeout(() => {
dragImage.remove();
}, 1);
}
return (
<div className={(props.className ? props.className + ' ' : '') + 'flex flex-row flex-grow-0 text-xs text-justify'}>
<div draggable="true" onDragStart={onDragStart} className={(props.className ? props.className + ' ' : '') + 'flex flex-row flex-grow-0 text-xs text-justify'}>
<div
className={'bg-secondary-200 ' + (corner !== 'square' ? 'rounded' : '')}
style={{
......
......@@ -185,8 +185,8 @@ export const QueryBuilderInner = (props: QueryBuilderProps) => {
graphologyGraph.addPill2Graphology(
{
type: QueryElementTypes.Entity,
x: position.x,
y: position.y,
x: position.x - (150 / 2),
y: position.y - (24 / 2),
name: dragData.name,
schemaKey: dragData.name,
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment