fix(ui): always render ProfileCropper in tree, use OnParametersSet to trigger JS init
This commit is contained in:
@@ -54,15 +54,13 @@
|
||||
OnClosed="CloseAssetPicker" />
|
||||
}
|
||||
|
||||
@if (showCropper && profileAssetId.HasValue) {
|
||||
< ProfileCropper Show="true"
|
||||
AssetId="profileAssetId"
|
||||
CropX="cropX"
|
||||
CropY="cropY"
|
||||
CropZoom="cropZoom"
|
||||
OnCropped="OnCropped"
|
||||
OnClosed="CloseCropper" />
|
||||
}
|
||||
<ProfileCropper Show="showCropper && profileAssetId.HasValue"
|
||||
AssetId="profileAssetId"
|
||||
CropX="cropX"
|
||||
CropY="cropY"
|
||||
CropZoom="cropZoom"
|
||||
OnCropped="OnCropped"
|
||||
OnClosed="CloseCropper" />
|
||||
|
||||
@code {
|
||||
/// <summary>
|
||||
|
||||
@@ -89,8 +89,17 @@
|
||||
_instanceId = ++_counter;
|
||||
}
|
||||
|
||||
protected override void OnParametersSet() {
|
||||
if (Show && AssetId.HasValue) {
|
||||
_pendingInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool _pendingInit;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender) {
|
||||
if (firstRender && Show && AssetId.HasValue) {
|
||||
if (_pendingInit) {
|
||||
_pendingInit = false;
|
||||
await jsRuntime.InvokeVoidAsync("profileCropper.initialize",
|
||||
ContainerId, ImageUrl, CropX ?? 50, CropY ?? 50, CropZoom ?? 1f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user