-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blazor WebAssembly App - BlazorTransitionableRoute implementation
- Loading branch information
1 parent
f479d5d
commit 396c18e
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
9 changes: 8 additions & 1 deletion
9
demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/App.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
demo/aspnetcore6.0/v4/BlazorTransitionableRouteDemoWasm/Client/Shared/MyViewLayout.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
@inherits TransitionableLayoutComponent | ||
@using BlazorTransitionableRouteDemoWasm.Client.Pages | ||
|
||
<div class="transition @transitioningClass @(Transition.IntoView ? "transitioned" : "transitioned_behind")"> | ||
@Body | ||
</div> | ||
|
||
<style> | ||
.transition { | ||
position: absolute; | ||
} | ||
.transitioned { | ||
z-index: 1; | ||
} | ||
.transitioned_behind { | ||
z-index: 0; | ||
} | ||
</style> | ||
|
||
@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" ) } | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters