docs(canvas): explain node editing scopes and display interactions
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
/**
|
||||
* 编辑手势的能力对象:一次交互取得preview/commit/cancel,再由有效性护栏限制其后续调用。
|
||||
* 这里只校验调用当刻是否仍有效,不维护手势状态机,也不自行保证commit只能调用一次。
|
||||
*/
|
||||
/** A captured pointer may only finish the exact interaction that acquired it. */
|
||||
/** preview产生临时显示,commit结束并提交,cancel撤销本次预览;具体语义由创建租约的编辑器实现。 */
|
||||
export type EditingLease<T> = { preview(value: T): void; commit(): void; cancel(): void };
|
||||
|
||||
/** 冻结包装后的方法表,每次调用重新检查isCurrent;过期事件静默忽略,不能结束另一场交互。 */
|
||||
export function guardEditingLease<T>(isCurrent: () => boolean, actions: EditingLease<T>): EditingLease<T> {
|
||||
return Object.freeze({
|
||||
// 指针移动可能持续产生事件,必须逐次检查,不能只在创建租约时检查一次。
|
||||
preview(value: T) { if (isCurrent()) actions.preview(value); },
|
||||
// 提交与取消共用同一有效性判断;原actions负责释放手势与处理重复结束。
|
||||
commit() { if (isCurrent()) actions.commit(); },
|
||||
cancel() { if (isCurrent()) actions.cancel(); },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user