Skip to content

Commit

Permalink
fix: remove macOS dragging preview image when resizing DRD overview
Browse files Browse the repository at this point in the history
  • Loading branch information
jarekdanielak authored and philippfromme committed Jan 15, 2025
1 parent c621e21 commit 0c39640
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions client/src/util/dom/dragger.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
* except in compliance with the MIT License.
*/

import {
domify
} from 'min-dom';

// This is a 1x1px transparent GIF. It's used to override the default drag preview image.
// For macOS, this has to be an actual image and has to be loaded before we set it.
const EMPTY_IMAGE = new Image(1, 1);
EMPTY_IMAGE.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';

/**
* Add a dragger that calls back the passed function with
Expand Down Expand Up @@ -45,7 +45,7 @@ export default function createDragger(fn) {

// (1) prevent preview image
if (event.dataTransfer) {
event.dataTransfer.setDragImage(emptyCanvas(), 0, 0);
event.dataTransfer.setDragImage(EMPTY_IMAGE, 0, 0);
}

// (2) setup drag listeners
Expand Down Expand Up @@ -75,11 +75,6 @@ export default function createDragger(fn) {
return onDragStart;
}


function emptyCanvas() {
return domify('<canvas width="0" height="0" />');
}

function preventDefault(event) {
event.preventDefault();
event.stopPropagation();
Expand Down

0 comments on commit 0c39640

Please sign in to comment.