Skip to content

Commit 84bebc3

Browse files
authored
Merge pull request #63 from zHaytam/develop
Version 1.4.1
2 parents 78f954c + 8a500d8 commit 84bebc3

File tree

8 files changed

+30
-8
lines changed

8 files changed

+30
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## Diagrams [1.4.1] - 2020-12-24
8+
9+
### Added
10+
11+
- `EnableVirtualization` option: whether to only render visible nodes or not.
12+
- `RegisterModelComponent` overload that takes `Type`s as input for dynamic registrations.
13+
714
## Diagrams [1.4.0] - 2020-12-12
815

916
### Added

samples/SharedDemo/Demos/Simple.razor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
<input id="panningCheckbox" type="checkbox" class="custom-control-input" @onchange="TogglePanning" checked />
2424
<label class="custom-control-label" for="panningCheckbox">Toggle Panning</label>
2525
</div>
26+
<div class="custom-control custom-checkbox ml-2">
27+
<input id="virtualizationCheckbox" type="checkbox" class="custom-control-input" @onchange="ToggleVirtualization" checked />
28+
<label class="custom-control-label" for="virtualizationCheckbox">Toggle Virtualization</label>
29+
</div>
2630
</div>
2731

2832
<CascadingValue Name="DiagramManager" Value="diagramManager">

samples/SharedDemo/Demos/Simple.razor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ protected override void OnInitialized()
2525

2626
protected void TogglePanning() => diagramManager.Options.AllowPanning = !diagramManager.Options.AllowPanning;
2727

28+
protected void ToggleVirtualization()
29+
=> diagramManager.Options.EnableVirtualization = !diagramManager.Options.EnableVirtualization;
30+
2831
private NodeModel NewNode(double x, double y)
2932
{
3033
var node = new NodeModel(new Point(x, y));

src/Blazor.Diagrams.Core/Blazor.Diagrams.Core.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<PackageLicenseExpression>MIT</PackageLicenseExpression>
88
<Authors>zHaytam</Authors>
99
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
10-
<AssemblyVersion>1.4.0</AssemblyVersion>
11-
<FileVersion>1.4.0</FileVersion>
10+
<AssemblyVersion>1.4.1</AssemblyVersion>
11+
<FileVersion>1.4.1</FileVersion>
1212
<RepositoryUrl>https://github.com/zHaytam/Blazor.Diagrams</RepositoryUrl>
13-
<Version>1.4.0</Version>
13+
<Version>1.4.1</Version>
1414
<PackageId>Z.Blazor.Diagrams.Core</PackageId>
1515
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
1616
<Product>Z.Blazor.Diagrams.Core</Product>

src/Blazor.Diagrams.Core/DiagramManager.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,14 @@ public void UnregisterSubManager<T>() where T : DiagramSubManager
278278
}
279279

280280
public void RegisterModelComponent<M, C>() where M : Model where C : ComponentBase
281+
=> RegisterModelComponent(typeof(M), typeof(C));
282+
283+
public void RegisterModelComponent(Type modelType, Type componentType)
281284
{
282-
var modelType = typeof(M);
283285
if (_componentByModelMapping.ContainsKey(modelType))
284286
throw new Exception($"Component already registered for model '{modelType.Name}'.");
285287

286-
_componentByModelMapping.Add(modelType, typeof(C));
288+
_componentByModelMapping.Add(modelType, componentType);
287289
}
288290

289291
public Type? GetComponentForModel<M>(M model) where M : Model

src/Blazor.Diagrams.Core/DiagramOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class DiagramOptions
1818
public bool AllowMultiSelection { get; set; } = true;
1919
[Description("Whether to allow panning or not")]
2020
public bool AllowPanning { get; set; } = true;
21+
[Description("Only render visible nodes")]
22+
public bool EnableVirtualization { get; set; } = true;
2123

2224
public DiagramZoomOptions Zoom { get; set; } = new DiagramZoomOptions();
2325
public DiagramLinkOptions Links { get; set; } = new DiagramLinkOptions();

src/Blazor.Diagrams/Blazor.Diagrams.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<RazorLangVersion>3.0</RazorLangVersion>
66
<Authors>zHaytam</Authors>
77
<PackageLicenseExpression>MIT</PackageLicenseExpression>
8-
<AssemblyVersion>1.4.0</AssemblyVersion>
9-
<FileVersion>1.4.0</FileVersion>
8+
<AssemblyVersion>1.4.1</AssemblyVersion>
9+
<FileVersion>1.4.1</FileVersion>
1010
<RepositoryUrl>https://github.com/zHaytam/Blazor.Diagrams</RepositoryUrl>
1111
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
12-
<Version>1.4.0</Version>
12+
<Version>1.4.1</Version>
1313
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1414
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
1515
<PackageId>Z.Blazor.Diagrams</PackageId>

src/Blazor.Diagrams/Components/Renderers/NodeRenderer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
129129

130130
private async void CheckVisibility()
131131
{
132+
// _isVisible must be true in case virtualization gets disabled and some nodes are hidden
133+
if (!DiagramManager.Options.EnableVirtualization && _isVisible)
134+
return;
135+
132136
if (Node.Size == null)
133137
return;
134138

0 commit comments

Comments
 (0)