question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent MouseEventArgs OffestX and OffestY in Blazor

See original GitHub issue

Describe the bug

When using MouseEventArgs.OffsetX and.OffsetY as endpoint coordinates when drawing a line inside of a svg element, the rendered line appears to “snap” to a seemingly random position. This does not happen when I account for the offset on my own. Problem occurs specifically when moving the mouse towards the start position of the line element that is created on left button mouse click…

To Reproduce

I made a repo to demonstrate, and the only relevant file (as in modified from template) is Index.razor. https://github.com/Phexyaa/BlazorMouseEventOffsetDemo

Exceptions (if any)

Further technical details

  • ASP.NET Core version 5

  • Include the output of dotnet --info .NET SDK (reflecting any global.json): Version: 5.0.100 Commit: 5044b93829

Runtime Environment: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.100\

Host (useful for support): Version: 5.0.0 Commit: cf258a14b7

.NET SDKs installed: 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.604 [C:\Program Files\dotnet\sdk] 2.1.700 [C:\Program Files\dotnet\sdk] 2.2.102 [C:\Program Files\dotnet\sdk] 2.2.204 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 3.1.403 [C:\Program Files\dotnet\sdk] 5.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and it’s version Visual Studio Community 2019 V16.8.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SteveSandersonMScommented, Nov 24, 2020

@Phexyaa I’m afraid I don’t know. This seems to be purely a question about the browser’s internal behaviors. Sorry I can’t give an authoritative answer!

0reactions
Phexyaacommented, Nov 24, 2020

Thank you for the info, I have one more thing to ask regarding this before I go. The issue only arises when i change the end point of the line (otherwise coordinates are as expected), which in turn causes the line to be re-rendered. (At least to my understanding) Is there a chance this affects what element’s offset gets passed through? Like, is there a chance the offset that is given is somehow becoming the offset of the line element instead of the svg behind the scenes?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor MouseEventArgs for click event missing offsetX and ...
Trying to determine where within an element the user clicked. Normally use MouseEvent.offsetX and MouseEvent.offsetY for this, but they are ...
Read more >
C#, ASP.NET Core Blazor, TouchEventArgs has no OffsetX
I can only choose between PageX, ScreenX and ClientX and all of them return the same value, and seems to be offset from...
Read more >
MouseEventArgs.OffsetX Property
The X coordinate of the mouse pointer in relative (Target Element) coordinates. public: property double OffsetX { double get(); void set(double value); };....
Read more >
What's New in v22.2 - Latest Version
This property allows you to specify left horizontal offset for content displayed in preview sections. Skinned Paddings and Configurable Indent in TreeList ...
Read more >
Bug and Issue Tracker - YouTrackReSharper (RSRP)
Message = “TextView has disconnected from TextControl on TextViewDataChanged.” ExceptionPath = Root ClassName = JetBrains.Util.LoggerException. Data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found