From 999c512aa118ec8b81cffd32d40830bae8fb445d Mon Sep 17 00:00:00 2001 From: vbenoit Date: Wed, 9 Oct 2024 20:54:55 +0000 Subject: [PATCH] update --- .../football-field/football-field.component.css | 4 ++-- .../football-field/football-field.component.html | 10 ++++++---- .../football-field/football-field.component.ts | 16 ++++++++++------ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/app/football-field/football-field.component.css b/src/app/football-field/football-field.component.css index 0bd71bc..addf118 100644 --- a/src/app/football-field/football-field.component.css +++ b/src/app/football-field/football-field.component.css @@ -76,7 +76,7 @@ canvas { .timeline { position: relative; width: 100%; - height: 40px; + height: 20px; background-color: #f0f0f0; border: 1px solid #ccc; display: flex; @@ -85,7 +85,7 @@ canvas { .timeline-block { position: absolute; - height: 30px; + height: 15px; background-color: blue; border: 1px solid black; cursor: move; diff --git a/src/app/football-field/football-field.component.html b/src/app/football-field/football-field.component.html index 1a4de3a..8fb3cf3 100644 --- a/src/app/football-field/football-field.component.html +++ b/src/app/football-field/football-field.component.html @@ -67,10 +67,12 @@ {{ player.id }}
+ class="timeline-block" + [style.left]="calculateLeftPosition(step)" + [style.width]="calculateBlockWidth(step)" + (mousedown)="onTimelineBlockMouseDown($event, player, i)" + (mousemove)="onMouseMove($event)" + (mouseup)="onMouseUp()">
diff --git a/src/app/football-field/football-field.component.ts b/src/app/football-field/football-field.component.ts index 0ce304f..a2c401c 100644 --- a/src/app/football-field/football-field.component.ts +++ b/src/app/football-field/football-field.component.ts @@ -128,8 +128,8 @@ export class FootballFieldComponent { public dragOffsetX: number = 0; ngOnInit() { - this.ctx = this.canvas.nativeElement.getContext('2d')!; - this.drawField(); + this.ctx = this.canvas.nativeElement.getContext('2d')!; + this.drawField(); this.createPlayers(); this.createPlots(); this.createPiquets(); @@ -298,9 +298,9 @@ export class FootballFieldComponent { destinationY: null, isMoving:false, progress: 0, - startX: 0, + startX: 0, startY: 0, - timeline: [], + timeline: [], currentStepIndex: 0 }); } this.drawField(); @@ -324,9 +324,9 @@ export class FootballFieldComponent { destinationY: null, isMoving:false, progress: 0, - startX: 0, + startX: 0, startY: 0, - timeline: null, + timeline: null, currentStepIndex: 0 }); } this.drawField(); @@ -927,6 +927,7 @@ export class FootballFieldComponent { // Si la souris clique dans un bloc if (x >= blockStartX && x <= blockEndX) { + console.log("clique dans un bloc !"); // Début du déplacement du bloc this.isTimelineDragging = true; this.draggedTimelinePlayer = player; @@ -939,6 +940,7 @@ export class FootballFieldComponent { } onTimelineBlockMouseDown(event: MouseEvent, player: Circle, index: number) { + console.log("onTimelineBlockMouseDown"); this.isTimelineDragging = true; this.draggedTimelinePlayer = player; this.draggedTimelineIndex = index; @@ -946,6 +948,7 @@ export class FootballFieldComponent { onMouseMove(event: MouseEvent) { if (this.isTimelineDragging && this.draggedTimelinePlayer) { + console.log("onMouseMove"); const { x } = this.getMousePos(event); const totalDuration = this.getTotalTimelineDuration(); const newStartTime = (x / this.canvas.nativeElement.width) * totalDuration; @@ -963,6 +966,7 @@ export class FootballFieldComponent { } onMouseUp() { + console.log("onMouseUp"); if (this.isTimelineDragging) { this.isTimelineDragging = false; this.draggedTimelinePlayer = null;