fix: re-init scroll animations after data loads from DB
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 6m55s

- initScrollAnimations ran only on firstRender when data wasn't loaded yet
- Items with fade-in-up class stayed invisible (opacity:0) after data render
- Now tracks _dataLoaded/_animationsInitialized flags to re-init JS after data loads
- Also fixes stat counter animations not running (stats were empty on firstRender)
This commit is contained in:
masoodafar-web
2026-02-17 23:57:41 +03:30
parent be78bc683a
commit bf0eb089bb
3 changed files with 12 additions and 22 deletions
+9 -1
View File
@@ -26,6 +26,10 @@ public partial class Index : IDisposable
private List<TestimonialItem> _testimonials = new();
private List<QA> _faqs = new();
// Track whether animations need re-initialization after data load
private bool _dataLoaded;
private bool _animationsInitialized;
protected override async Task OnInitializedAsync()
{
MainService.OnChangeHandler += OnStateChanged;
@@ -45,6 +49,7 @@ public partial class Index : IDisposable
}
PopulateFromSettings();
_dataLoaded = true;
// Load latest published blog posts
try
@@ -222,8 +227,11 @@ public partial class Index : IDisposable
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
// Init/re-init scroll animations after data is loaded and rendered
if ((firstRender || (_dataLoaded && !_animationsInitialized)) && _steps.Any())
{
_animationsInitialized = true;
// Init scroll-triggered fade-in animations
await JS.InvokeVoidAsync("initScrollAnimations");
+3 -3
View File
@@ -19,7 +19,7 @@
</MudHidden>
<div class="d-flex align-center gap-2">
<MudLink Href="@(RouteConstants.Main.MainPage)" Underline="Underline.None">
<MudLink Href="@(_isAuthenticated ? RouteConstants.Profile.Index : RouteConstants.Main.MainPage)" Underline="Underline.None">
<MudStack Row="true" Spacing="3" AlignItems="AlignItems.Center">
<MudHidden Breakpoint="Breakpoint.MdAndUp" Invert="true">
<MudImage ObjectFit="ObjectFit.Cover"
@@ -285,9 +285,9 @@
else
{
@* ── Default bottom nav (outside stores) ── *@
<MudLink Href="@(RouteConstants.Profile.Index)" Class="bottom-nav-item">
<MudLink Href="@(_isAuthenticated ? RouteConstants.Profile.Index : RouteConstants.Main.MainPage)" Class="bottom-nav-item">
<MudIcon Icon="@Icons.Material.Outlined.Home" Size="Size.Medium" />
<MudText Typo="Typo.caption">خانه</MudText>
<MudText Typo="Typo.caption">@(_isAuthenticated ? "داشبورد" : "خانه")</MudText>
</MudLink>
@if (_isAuthenticated)
{
@@ -1,18 +0,0 @@
{
"GwUrl": "https://cms.kbs2.ir",
"DownloadUrl": "",
"EncryptionSettings": {
"Key": "kmcQ3XTmH4mrdh8VHziuscyf8LLYjG//Kyni81nH/0E=",
"IV": "1wyF3Tt142MOkCpIyCxh/g=="
},
"SignalR": {
"HubPath": "/hubs/token-notification"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}