I'm creating a popup component and I want this to be movable. I can move it using the top / left style, but for now they are init to top:0;left:0; and so the popup appear on the top left corner of the page. I'm looking to make it appear on the center of the page and then get the Top Left coordinates of my div in ordor to manage properly my calcul after.
here is what I have now:
<div class="child-window" draggable="true" style="position:absolute; top: @(offsetY)px; left: @(offsetX)px; border-color: black;" @ondragend="OnDragEnd" @ondragstart="OnDragStart"><div class="cw-content"> @Content</div></div>@code { private double startX, startY, offsetX, offsetY; protected override void OnInitialized() { base.OnInitialized(); ResetStartPosition(); } private void ResetStartPosition() { //Set offsetX & offsetY to the top left div position } private void OnDragStart(DragEventArgs args) { startX = args.ClientX; startY = args.ClientY; } private void OnDragEnd(DragEventArgs args) { offsetX += args.ClientX - startX; offsetY += args.ClientY - startY; }}