Make ToggleThumbnails method asynchronous
Refactor the `ToggleThumbnails` method to be asynchronous (`async Task`) to support asynchronous operations. Add logic to re-render thumbnails when toggled on, including forcing a UI update, waiting for DOM rendering, and invoking `RenderThumbnailsAsync`. These changes improve the user experience by ensuring thumbnails are properly updated when displayed.
This commit is contained in:
@@ -318,8 +318,15 @@ protected override async Task OnInitializedAsync() {
|
||||
_currentZoom = (int)(scale * 100);
|
||||
}
|
||||
|
||||
void ToggleThumbnails() {
|
||||
async Task ToggleThumbnails() {
|
||||
_showThumbnails = !_showThumbnails;
|
||||
|
||||
// Re-render thumbnails when showing them
|
||||
if (_showThumbnails && _pdfLoaded) {
|
||||
await InvokeAsync(StateHasChanged); // Force UI update first
|
||||
await Task.Delay(150); // Wait for DOM to render canvas elements
|
||||
await RenderThumbnailsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
async Task GoToPageFromThumbnail(int pageNum) {
|
||||
|
||||
Reference in New Issue
Block a user