Only call onChange when the pieces have actually changed.

pull/2803/head
Brandon Evans 2017-03-17 12:16:22 -05:00
parent 581e0621e9
commit 94fefb254b
1 changed files with 3 additions and 1 deletions

View File

@ -48,6 +48,7 @@ function onMouseEvent(ctrl) {
if (sel === 'trash') {
pieces[key] = false;
ctrl.chessground.setPieces(pieces);
ctrl.onChange();
} else {
var existingPiece = ctrl.chessground.state.pieces[key];
var piece = {};
@ -62,14 +63,15 @@ function onMouseEvent(ctrl) {
) {
pieces[key] = false;
ctrl.chessground.setPieces(pieces);
ctrl.onChange();
} else if (e.type === 'mousedown' || e.type === 'touchstart' || key !== lastKey) {
pieces[key] = piece;
ctrl.chessground.cancelMove();
ctrl.chessground.setPieces(pieces);
ctrl.onChange();
}
}
lastKey = key;
ctrl.onChange();
} else if (isRightClick(e)) {
if (sel !== 'pointer') {
ctrl.chessground.state.drawable.current = undefined;