As a new developer, I am currently working on my personal chess project and have recently mastered the drag and drop system. However, I would like to explore different methods for achieving this. Is there a way to eliminate the white background in the process?
One potential solution could involve removing the white background from the ghost image.
An alternative approach might be to replace the ghost image with the actual image being dragged.
Alternatively, it could be an option to completely remove the ghost image while dragging, as the piece can still be viewed in each square when hovering over it.
If any of these solutions are feasible, it would be greatly appreciated!
Here is the link to my ongoing project: https://codepen.io/ThalisonAmaral/full/qBYZmZq. You will likely need to work with the dragstart()
function.
function dragstart() {
squaresDrop.forEach(square => square.classList.add('highlight'));
this.classList.add('is-dragging');
}
The Drag and Drop functionality can be found towards the end of the Js Code file. Since I am not entirely sure about the specifics of what I am dealing with, I have attempted to find possible solutions by using DataTransfer.setDragImage()
without much success.
I initially thought that using it could help in replacing the ghost image with an actual image, but upon further review, it doesn't seem to address the issue directly. However, I may be mistaken in my understanding.