task(A2): tool dispatcher behind flag
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* session.ts – Minimaler Werkzeug-Sitzungszustand (Task A2).
|
||||
*
|
||||
* phase 'idle' : kein Ziehen aktiv, Tool wartet auf down
|
||||
* phase 'active' : down ist erfolgt; Tool zieht/zeichnet bis up/cancel
|
||||
*
|
||||
* Der Dispatcher nutzt das, um move-Events nur während aktiver Sitzung an
|
||||
* Handler durchzureichen (und als Guard gegen verlorene up-Events).
|
||||
*/
|
||||
export type ToolPhase = 'idle' | 'active';
|
||||
|
||||
export class ToolSession {
|
||||
private current: ToolPhase = 'idle';
|
||||
|
||||
/** Ist eine Zeichensitzung aktiv (zwischen down und up)? */
|
||||
get isActive(): boolean {
|
||||
return this.current === 'active';
|
||||
}
|
||||
|
||||
/** Aktuelle Phase. */
|
||||
get phase(): ToolPhase {
|
||||
return this.current;
|
||||
}
|
||||
|
||||
/** Startet eine Sitzung (nach einem gültigen down). */
|
||||
begin(): void {
|
||||
this.current = 'active';
|
||||
}
|
||||
|
||||
/** Beendet die Sitzung regulär (up) oder abgebrochen (cancel/ESC). */
|
||||
end(): void {
|
||||
this.current = 'idle';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user