diff --git a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/App.razor b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/App.razor index a9fb8ac..dec47b3 100644 --- a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/App.razor +++ b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/App.razor @@ -1,7 +1,14 @@  - + + + + + + + + diff --git a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/Program.cs b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/Program.cs index b1a6031..9a49e0f 100644 --- a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/Program.cs +++ b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/Program.cs @@ -15,4 +15,6 @@ builder.Services.AddApiAuthorization(); +builder.Services.AddScoped(); + await builder.Build().RunAsync(); diff --git a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/Shared/MyViewLayout.razor b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/Shared/MyViewLayout.razor new file mode 100644 index 0000000..842b4be --- /dev/null +++ b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/Shared/MyViewLayout.razor @@ -0,0 +1,45 @@ + +@inherits TransitionableLayoutComponent +@using BlazorTransitionableRouteDemoWasm.Client.Pages + +
+ @Body +
+ + + +@code { + private string transitioningClass => Transition.FirstRender + ? "" : $"animate__{transitioningEffect()} animate__faster animate__animated"; + + private string transitioningEffect() + { + if (customTransitions.TryGetValue((TransitionType.fromType, TransitionType.toType), out var custom)) + { + return Transition.IntoView ? custom.effectIn : custom.effectOut; + } + else + { + var effect = Transition.IntoView ? "fadeIn" : "fadeOut"; + var direction = Transition.Backwards ? "Up" : "Down"; + return effect + direction; + } + } + + private Dictionary<(Type from, Type to), (string effectOut, string effectIn)> customTransitions = + new Dictionary<(Type from, Type to), (string effectOut, string effectIn)> + { + { (typeof(FetchData), typeof(WeatherDetail)), ( "fadeOutLeft", "fadeInRight" ) }, + { (typeof(WeatherDetail), typeof(FetchData)), ( "fadeOutRight", "fadeInLeft" ) } + }; +} \ No newline at end of file diff --git a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/_Imports.razor b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/_Imports.razor index 682df54..ee8cde7 100644 --- a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/_Imports.razor +++ b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/_Imports.razor @@ -9,3 +9,5 @@ @using Microsoft.JSInterop @using BlazorTransitionableRouteDemoWasm.Client @using BlazorTransitionableRouteDemoWasm.Client.Shared + +@using BlazorTransitionableRoute diff --git a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/wwwroot/index.html b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/wwwroot/index.html index 9a5ec27..56dd405 100644 --- a/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/wwwroot/index.html +++ b/demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/wwwroot/index.html @@ -12,6 +12,7 @@ +