本文整理汇总了TypeScript中chessground/api.Api.cancelMove方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Api.cancelMove方法的具体用法?TypeScript Api.cancelMove怎么用?TypeScript Api.cancelMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chessground/api.Api
的用法示例。
在下文中一共展示了Api.cancelMove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: ctrl
export function ctrl(cg: ChessgroundApi, step: Step, redraw: Redraw): KeyboardMove {
let focus = false;
let handler: KeyboardMoveHandler | undefined;
let preHandlerBuffer = step.fen;
const select = function(key: cg.Key): void {
if (cg.state.selected === key) cg.cancelMove();
else cg.selectSquare(key, true);
};
let usedSan = false;
return {
update(step) {
if (handler) handler(step.fen, cg.state.movable.dests);
else preHandlerBuffer = step.fen;
},
registerHandler(h: KeyboardMoveHandler) {
handler = h;
if (preHandlerBuffer) handler(preHandlerBuffer, cg.state.movable.dests);
},
hasFocus: () => focus,
setFocus(v) {
focus = v;
redraw();
},
san(orig, dest) {
usedSan = true;
cg.cancelMove();
select(orig);
select(dest);
},
select,
hasSelected: () => cg.state.selected,
usedSan
};
}
示例2: function
const select = function(key: cg.Key): void {
if (cg.state.selected === key) cg.cancelMove();
else cg.selectSquare(key, true);
};