fix(module: image): disables previewing error images and hides buttons when there is only one image (#1060)

This commit is contained in:
James Yeung 2021-01-30 23:39:40 +08:00 committed by GitHub
parent def6eca435
commit 2b82f3bdbd
4 changed files with 13 additions and 14 deletions

View File

@ -94,9 +94,10 @@ namespace AntDesign
private void HandleOnError()
{
Src = Fallback;
_loaded = true;
_isError = true;
Src = Fallback;
}
private void HandleOnLoad()

View File

@ -21,10 +21,13 @@
<div class="ant-image-preview-img-wrapper" style="transform: translate3d(0px, 0px, 0px);">
<img class="ant-image-preview-img" src="@ImageRef.ImageSrc" style="transform: scale3d(@_zoomOutTimes, @_zoomOutTimes, 1) rotate(@(90*_rotateTimes)deg);">
</div>
@if (ImageRef.ImageCount > 1)
{
<div class="ant-image-preview-switch-left @(ImageRef.CurrentIndex==0?"ant-image-preview-switch-left-disabled":"")" @onclick="()=>ImageRef.SwitchTo(ImageRef.CurrentIndex-1)" @onclick:stopPropagation>
<Icon Type="left" />
</div>
<div class="ant-image-preview-switch-right @(ImageRef.CurrentIndex==ImageRef.ImageCount-1?"ant-image-preview-switch-right-disabled":"")" @onclick="()=>ImageRef.SwitchTo(ImageRef.CurrentIndex+1)" @onclick:stopPropagation>
<Icon Type="right" />
</div>
}
</Dialog>

View File

@ -8,9 +8,6 @@ namespace AntDesign
[Parameter]
public ImageRef ImageRef { get; set; }
[Inject]
private ImageService ImageService { get; set; }
private int _zoomOutTimes = 1;
private int _rotateTimes;
private bool _visible = true;
@ -21,7 +18,8 @@ namespace AntDesign
StateHasChanged();
// Blocking DOM removal
await Task.Delay(200);
ImageService.CloseImage(ImageRef);
ImageRef.Close();
}
private void HandleZoomIn()

View File

@ -10,9 +10,6 @@ namespace AntDesign
[Parameter]
public RenderFragment ChildContent { get; set; }
[Inject]
private ImageService ImageService { get; set; }
internal IList<Image> Images => _images;
private IList<Image> _images;