[frontend/components] Scroll to attachment that was clicked on (ISH-641)
This commit is contained in:
parent
35c4babd63
commit
8a7bcde0c3
3 changed files with 14 additions and 11 deletions
|
@ -8,12 +8,13 @@
|
|||
<div class="wrapper" @onclick="Open" @onclick:stopPropagation="true">
|
||||
@if (Attachment.ContentType.StartsWith("image"))
|
||||
{
|
||||
<img class="attachment @(BlurImage ? "blur-image" : "")" src="@Attachment.Url" alt="@Attachment.AltText" fetchpriority="low"/>
|
||||
<img class="attachment @(BlurImage ? "blur-image" : "")" src="@Attachment.Url" alt="@Attachment.AltText"
|
||||
fetchpriority="low"/>
|
||||
}
|
||||
// else if (Attachment.ContentType == "audio/x-mod")
|
||||
// {
|
||||
// TODO: Module player
|
||||
// }
|
||||
// else if (Attachment.ContentType == "audio/x-mod")
|
||||
// {
|
||||
// TODO: Module player
|
||||
// }
|
||||
else if (Attachment.ContentType.StartsWith("audio"))
|
||||
{
|
||||
<audio controls class="attachment @(BlurImage ? "blur-image" : "")" src="@Attachment.Url"></audio>
|
||||
|
@ -49,8 +50,8 @@
|
|||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] [EditorRequired] public required NoteAttachment Attachment { get; set; }
|
||||
[Parameter] [EditorRequired] public required EventCallback OnOpen { get; set; }
|
||||
[Parameter] [EditorRequired] public required NoteAttachment Attachment { get; set; }
|
||||
[Parameter] [EditorRequired] public required EventCallback<NoteAttachment> OnOpen { get; set; }
|
||||
|
||||
private bool BlurImage { get; set; }
|
||||
|
||||
|
@ -63,7 +64,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
OnOpen.InvokeAsync();
|
||||
OnOpen.InvokeAsync(Attachment);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,10 +81,12 @@
|
|||
await Module.InvokeVoidAsync("scrollTo", _refs[Focused]);
|
||||
}
|
||||
|
||||
public async Task OpenDialog()
|
||||
public async Task OpenDialog(NoteAttachment attachment)
|
||||
{
|
||||
await Module.InvokeVoidAsync("openDialog", Dialog);
|
||||
ScrollWidth = await Module.InvokeAsync<int>("getScrollWidth", Scroller);
|
||||
var index = Attachments.IndexOf(attachment);
|
||||
await Module.InvokeVoidAsync("scrollTo", _refs[index]);
|
||||
}
|
||||
|
||||
private async Task CloseDialog()
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
[Parameter] [EditorRequired] public required IList<NoteAttachment> Attachments { get; set; }
|
||||
private AttachmentView View { get; set; } = null!;
|
||||
|
||||
private async Task Open()
|
||||
private async Task Open(NoteAttachment attachment)
|
||||
{
|
||||
await View.OpenDialog();
|
||||
await View.OpenDialog(attachment);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue