Skip to content
Snippets Groups Projects

Fix/safari drag

Merged Leonardo Christino requested to merge fix/safari-drag into main
2 files
+ 24
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -56,8 +56,26 @@ 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);
const mouse_x = event.clientX - pill.getBoundingClientRect().left;
const mouse_y = event.clientY - pill.getBoundingClientRect().top;
event.dataTransfer.setDragImage(dragImage, mouse_x, mouse_y);
event.dataTransfer.setData('mouse_x', String(mouse_x))
event.dataTransfer.setData('mouse_y', String(mouse_y))
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={{
Loading