Improve signature scaling and responsiveness in PDF viewer
Reduced delay in `OnZoomChanged` to improve responsiveness when rendering signature buttons. Added calls to `RenderSignatureButtonsAsync` in zoom-related methods to ensure signature overlays update dynamically. Refactored `pdf-viewer.js` to introduce `appliedSignatureElements` for better management of applied signatures. Added `scaleAppliedSignature` and `updateAppliedSignaturePositions` methods to dynamically scale and position applied signatures based on zoom level and page. Enhanced signature button rendering by scaling dimensions (width, height, font size, icon size) proportionally with zoom. Added attributes to store base values for applied signature containers to facilitate scaling. Improved handling of applied signatures to ensure proper scaling, positioning, and visibility during zoom and page navigation. These changes enhance user experience and maintain consistency across zoom levels.
This commit is contained in:
@@ -628,8 +628,8 @@ const int MaxThumbnailWidth = 400;
|
||||
_currentZoom = (int)(scale * 100);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
// Re-render signature buttons when zoom changes
|
||||
await Task.Delay(100);
|
||||
// Small delay for canvas render to complete (reduced from 100ms to 10ms)
|
||||
await Task.Delay(10);
|
||||
await RenderSignatureButtonsAsync();
|
||||
}
|
||||
|
||||
@@ -652,6 +652,9 @@ const int MaxThumbnailWidth = 400;
|
||||
await JSRuntime.InvokeVoidAsync("pdfViewer.zoomIn");
|
||||
var scale = await JSRuntime.InvokeAsync<double>("pdfViewer.getScale");
|
||||
_currentZoom = (int)(scale * 100);
|
||||
|
||||
// Update signature overlay positions after zoom
|
||||
await RenderSignatureButtonsAsync();
|
||||
}
|
||||
|
||||
async Task ZoomOut() {
|
||||
@@ -659,6 +662,9 @@ const int MaxThumbnailWidth = 400;
|
||||
await JSRuntime.InvokeVoidAsync("pdfViewer.zoomOut");
|
||||
var scale = await JSRuntime.InvokeAsync<double>("pdfViewer.getScale");
|
||||
_currentZoom = (int)(scale * 100);
|
||||
|
||||
// Update signature overlay positions after zoom
|
||||
await RenderSignatureButtonsAsync();
|
||||
}
|
||||
|
||||
async Task SetZoom(int percentage) {
|
||||
@@ -670,6 +676,9 @@ const int MaxThumbnailWidth = 400;
|
||||
async Task OnZoomSliderChanged(ChangeEventArgs e) {
|
||||
if (int.TryParse(e.Value?.ToString(), out var zoom)) {
|
||||
await SetZoom(zoom);
|
||||
|
||||
// Update signature overlay positions after zoom
|
||||
await RenderSignatureButtonsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user