Skip to content

Commit

Permalink
fix: use invariant culture for node positions in CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Jcparkyn committed Mar 24, 2021
1 parent 752d7ec commit 966648a
Showing 1 changed file with 57 additions and 56 deletions.
113 changes: 57 additions & 56 deletions Nodexr/Shared/Nodes/NodeView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@implements IDisposable

<div class="node @CssClass"
style="transform: translate(@((long)Data.Pos.x)px, @((long)Data.Pos.y)px); --col-node-accent:@Data.CssColor;"
style="transform: @CssTransform; --col-node-accent:@Data.CssColor;"
@ref="NodeDiv"
ondragleave="tempNoodle.setInvalid()"
ondragover="event.preventDefault(); tempNoodle.setValid();"
Expand Down Expand Up @@ -62,59 +62,60 @@


@functions{
[Parameter] public INode Data { get; set; }
ElementReference NodeDiv { get; set; }

string CssClass => NodeHandler.IsNodeSelected(Data) ? "node-selected" : "";

protected override void OnInitialized()
{
Data.OutputChanged += Refresh;
Data.LayoutChanged += Refresh;
Data.SelectionChanged += Refresh;
}

void ToggleCollapsed()
{
Data.IsCollapsed = !Data.IsCollapsed;
Data.OnLayoutChanged(this, EventArgs.Empty);
}

async Task StartDrag(MouseEventArgs e)
{
NodeDragService.OnStartNodeDrag(Data, e);
await JSRuntime.InvokeVoidAsync("NodeDragHandler.startNodeDrag");
}

void ShowModal()
{
var modalParameters = new ModalParameters();
modalParameters.Add(nameof(NodeInfo.InfoText), Data.NodeInfo);
Modal.Show<NodeInfo>(Data.Title, modalParameters);
}

void Refresh(object sender, EventArgs e)
{
StateHasChanged();
}

void Select(MouseEventArgs e)
{
if (!NodeDragService.IsDrag(e))
{
NodeHandler.SelectNode(Data);
}
}

void Deselect()
{
NodeHandler.DeselectAllNodes();
}

public void Dispose()
{
Data.OutputChanged -= Refresh;
Data.LayoutChanged -= Refresh;
Data.SelectionChanged -= Refresh;
}
[Parameter] public INode Data { get; set; }
ElementReference NodeDiv { get; set; }

string CssClass => NodeHandler.IsNodeSelected(Data) ? "node-selected" : "";
string CssTransform => FormattableString.Invariant($"translate({(long)Data.Pos.x}px, {(long)Data.Pos.y}px)");

protected override void OnInitialized()
{
Data.OutputChanged += Refresh;
Data.LayoutChanged += Refresh;
Data.SelectionChanged += Refresh;
}

void ToggleCollapsed()
{
Data.IsCollapsed = !Data.IsCollapsed;
Data.OnLayoutChanged(this, EventArgs.Empty);
}

async Task StartDrag(MouseEventArgs e)
{
NodeDragService.OnStartNodeDrag(Data, e);
await JSRuntime.InvokeVoidAsync("NodeDragHandler.startNodeDrag");
}

void ShowModal()
{
var modalParameters = new ModalParameters();
modalParameters.Add(nameof(NodeInfo.InfoText), Data.NodeInfo);
Modal.Show<NodeInfo>(Data.Title, modalParameters);
}

void Refresh(object sender, EventArgs e)
{
StateHasChanged();
}

void Select(MouseEventArgs e)
{
if (!NodeDragService.IsDrag(e))
{
NodeHandler.SelectNode(Data);
}
}

void Deselect()
{
NodeHandler.DeselectAllNodes();
}

public void Dispose()
{
Data.OutputChanged -= Refresh;
Data.LayoutChanged -= Refresh;
Data.SelectionChanged -= Refresh;
}
}

0 comments on commit 966648a

Please sign in to comment.