本文整理汇总了TypeScript中chessground/drag.dragNewPiece函数的典型用法代码示例。如果您正苦于以下问题:TypeScript dragNewPiece函数的具体用法?TypeScript dragNewPiece怎么用?TypeScript dragNewPiece使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dragNewPiece函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: drag
export function drag(ctrl: AnalyseCtrl, color: Color, e: cg.MouchEvent): void {
if (e.button !== undefined && e.button !== 0) return; // only touch or left click
if (ctrl.chessground.state.movable.color !== color) return;
const el = e.target as HTMLElement;
const role = el.getAttribute('data-role') as cg.Role,
number = el.getAttribute('data-nb');
if (!role || !color || number === '0') return;
e.stopPropagation();
e.preventDefault();
dragNewPiece(ctrl.chessground.state, { color, role }, e);
}
示例2: drag
export function drag(ctrl: RoundController, e: cg.MouchEvent): void {
if (e.button !== undefined && e.button !== 0) return; // only touch or left click
if (ctrl.replaying() || !ctrl.isPlaying()) return;
const el = e.target as HTMLElement,
role = el.getAttribute('data-role') as cg.Role,
color = el.getAttribute('data-color') as cg.Color,
number = el.getAttribute('data-nb');
if (!role || !color || number === '0') return;
e.stopPropagation();
e.preventDefault();
dragNewPiece(ctrl.chessground.state, { color, role }, e);
}