fix board editor drag piece into board

pull/625/head
Thibault Duplessis 2014-11-14 23:57:23 +01:00
parent b028131617
commit cbd86a2bee
1 changed files with 4 additions and 2 deletions

View File

@ -14,11 +14,12 @@ module.exports = function(ctrl, e) {
}); });
if (!key) return; if (!key) return;
var coords = util.key2pos(ctrl.chessground.data.orientation === 'white' ? key : util.invertKey(key)); var coords = util.key2pos(ctrl.chessground.data.orientation === 'white' ? key : util.invertKey(key));
var obj = {}; var piece = {
obj[key] = {
role: role, role: role,
color: color color: color
}; };
var obj = {};
obj[key] = piece;
ctrl.chessground.setPieces(obj); ctrl.chessground.setPieces(obj);
var bounds = ctrl.chessground.data.bounds(); var bounds = ctrl.chessground.data.bounds();
var squareBounds = e.target.parentNode.getBoundingClientRect(); var squareBounds = e.target.parentNode.getBoundingClientRect();
@ -28,6 +29,7 @@ module.exports = function(ctrl, e) {
]; ];
ctrl.chessground.data.draggable.current = { ctrl.chessground.data.draggable.current = {
orig: key, orig: key,
piece: piece.color + ' ' + piece.role,
rel: rel, rel: rel,
epos: [e.clientX, e.clientY], epos: [e.clientX, e.clientY],
pos: [e.clientX - rel[0], e.clientY - rel[1]], pos: [e.clientX - rel[0], e.clientY - rel[1]],