mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-02-12 05:35:14 +00:00
Carousel Navigate() method will reset timer
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
@foreach (var item in items)
|
||||
{
|
||||
var index = items.IndexOf(item);
|
||||
<a @onclick="@(args => GoTo(index))" class="rz-carousel-pager-button @(index == selectedIndex ? "rz-state-active" : "")"></a>
|
||||
<a @onclick="@(args => Navigate(index))" class="rz-carousel-pager-button @(index == selectedIndex ? "rz-state-active" : "")"></a>
|
||||
}
|
||||
</RadzenStack>
|
||||
}
|
||||
|
||||
@@ -80,6 +80,26 @@ namespace Radzen.Blazor
|
||||
/// Navigates to specific index.
|
||||
/// </summary>
|
||||
public async Task Navigate(int index)
|
||||
{
|
||||
if (Auto)
|
||||
{
|
||||
await Reset();
|
||||
}
|
||||
|
||||
await GoTo(index);
|
||||
}
|
||||
|
||||
async Task Prev()
|
||||
{
|
||||
await Navigate(selectedIndex == 0 ? items.Count - 1 : selectedIndex - 1);
|
||||
}
|
||||
|
||||
async Task Next()
|
||||
{
|
||||
await Navigate(selectedIndex == items.Count - 1 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
|
||||
async Task GoTo(int index)
|
||||
{
|
||||
if (selectedIndex != index)
|
||||
{
|
||||
@@ -91,26 +111,6 @@ namespace Radzen.Blazor
|
||||
}
|
||||
}
|
||||
|
||||
async Task Prev()
|
||||
{
|
||||
await GoTo(selectedIndex == 0 ? items.Count - 1 : selectedIndex - 1);
|
||||
}
|
||||
|
||||
async Task Next()
|
||||
{
|
||||
await GoTo(selectedIndex == items.Count - 1 ? 0 : selectedIndex + 1);
|
||||
}
|
||||
|
||||
async Task GoTo(int index)
|
||||
{
|
||||
if (Auto)
|
||||
{
|
||||
await Reset();
|
||||
}
|
||||
|
||||
await Navigate(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the auto-cycle timer.
|
||||
/// </summary>
|
||||
@@ -299,7 +299,7 @@ namespace Radzen.Blazor
|
||||
if (firstRender)
|
||||
{
|
||||
var ts = TimeSpan.FromMilliseconds(Interval);
|
||||
timer = new System.Threading.Timer(state => InvokeAsync(() => Navigate(selectedIndex + 1)),
|
||||
timer = new System.Threading.Timer(state => InvokeAsync(() => GoTo(selectedIndex + 1)),
|
||||
null, Auto ? ts : Timeout.InfiniteTimeSpan, ts);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user