-
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(PdfReader): add OnPageChangedAsync parameter #719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -37,6 +37,9 @@ public partial class PdfReader | |||
| private bool _isFitToPage; | ||||
| private uint _currentPage; | ||||
| private string? _url; | ||||
| private string? _currentScale; | ||||
|
|
||||
| private readonly HashSet<string> AllowedScaleValues = ["page-actual", "page-width", "page-height", "page-fit", "auto"]; | ||||
|
|
||||
|
Comment on lines
+42
to
43
|
||||
| private readonly HashSet<string> AllowedScaleValues = ["page-actual", "page-width", "page-height", "page-fit", "auto"]; |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,10 @@ | |||||||
| cursor: pointer; | ||||||||
| } | ||||||||
|
|
||||||||
| .bb-view-icon.disabled { | ||||||||
| color: #6c757d; | ||||||||
|
||||||||
| color: #6c757d; | |
| color: #6c757d; | |
| cursor: not-allowed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): The JS-driven scale changes don’t propagate back to the Blazor-bound CurrentScaleString, which can desync component state.
The
scalechanginghandler updatesscaleEl.valuebut never firesinput/changeor calls back into .NET, so Blazor is unaware of zoom changes made via the buttons or viewer controls. That meansCurrentScaleString/_currentScale/Options.CurrentScalecan diverge from the actual viewer scale. To keep them in sync, either dispatch aninputevent onscaleElafter updating it, or invoke a .NET method from JS (likepageChanged) to updateOptions.CurrentScale.Suggested implementation:
Because I only see a fragment of the Razor markup and not the JavaScript block, you may need to adjust the SEARCH section to match your actual
scalechanginghandler. Concretely:scalechangingevent (or equivalent) insidePdfReader.razor(often in a<script>block or a referenced JS file if inlined via @Inject IJSRuntime)..bb-view-scaleelement’svalue(the element bound via@bind="CurrentScaleString"), add:scaleSelect.dispatchEvent(new Event('input', { bubbles: true }));scaleSelect.dispatchEvent(new Event('change', { bubbles: true }));container.querySelector('.bb-view-scale')) is targeting the same input you bound with@bind="CurrentScaleString"; if your variable is namedscaleElinstead ofscaleSelect, update the snippet accordingly.scalechanginghandler currently uses different variable names or structure, keep the existing logic and only add the twodispatchEventcalls right after thevalueassignment to keep Blazor’sCurrentScaleString/_currentScale/Options.CurrentScalein sync with the actual viewer scale.