diff --git a/BlazorCanvas/BlazorCanvas/Data/CanvasService.cs b/BlazorCanvas/BlazorCanvas/Data/CanvasService.cs index 449e2de..0b2b521 100644 --- a/BlazorCanvas/BlazorCanvas/Data/CanvasService.cs +++ b/BlazorCanvas/BlazorCanvas/Data/CanvasService.cs @@ -25,7 +25,7 @@ public class CanvasService { public async void OnMouseMove(MouseEventArgs eventArgs) { double mouseX = 0, mouseY = 0; - + if (eventArgs.Buttons == 0 || eventArgs.Buttons > 2) return; // Rien faire si aucun bouton est appuyé ou si les deux boutons/ d'autres boutons sont appuyés. @@ -37,8 +37,8 @@ public class CanvasService { JObject? offsets = (JObject?)JsonConvert.DeserializeObject(data); if (offsets is not null && offsets.HasValues) { // Translation entre le canvas et la souris. - mouseX = eventArgs.ClientX - offsets.Value("offsetLeft"); - mouseY = eventArgs.ClientY - offsets.Value("offsetTop"); + mouseX = eventArgs.PageX - offsets.Value("offsetLeft"); + mouseY = eventArgs.PageY - offsets.Value("offsetTop"); } if (_currentCanvasContext is null) _currentCanvasContext = await myCanvas.CreateCanvas2DAsync();