feat: drag and drop

This commit is contained in:
shahdlala66
2026-04-22 13:16:44 +02:00
parent 5951257c99
commit dc9a7b2e32
7 changed files with 228 additions and 6 deletions
@@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
@Component({
selector: 'app-chess-piece',
@@ -8,6 +8,22 @@ import { Component, Input } from '@angular/core';
})
export class ChessPieceComponent {
@Input({ required: true }) pieceCode: string | null = null;
@Input() draggable = false;
@Output() pieceDragStart = new EventEmitter<DragEvent>();
@Output() pieceDragEnd = new EventEmitter<void>();
onDragStart(event: DragEvent): void {
if (!this.draggable) {
event.preventDefault();
return;
}
this.pieceDragStart.emit(event);
}
onDragEnd(): void {
this.pieceDragEnd.emit();
}
get spriteUrl(): string {
if (!this.pieceCode) {