From ae5e76c8a187b6e2c6d44de3bd11653f6129e490 Mon Sep 17 00:00:00 2001 From: ame Date: Mon, 2 Sep 2024 13:44:30 -0500 Subject: set drag image --- public/board.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/board.js b/public/board.js index 7ba8507..1141a5c 100644 --- a/public/board.js +++ b/public/board.js @@ -23,9 +23,10 @@ function handle_highlight(elem) { return function(ev) { //validates if square has a piece, and it is it's turn - if(ev.type === "dragstart" && (!elem || !elem.hasChildNodes() || - !elem.children[0].classList.contains(to_move? "w" : "b"))){ - return false + if(ev.type === "dragstart"){ + if(!elem || !elem.hasChildNodes() || !elem.children[0].classList.contains(to_move? "w" : "b")) + return false + ev.dataTransfer.setDragImage(elem.children[0], 0, 0); } let moves = move(board, elem.id.charCodeAt(0) - 48, elem.id.charCodeAt(1) - 48, to_move) -- cgit v1.2.3