[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,7 +8,8 @@
|
||||||
<div class="wrapper" @onclick="Open" @onclick:stopPropagation="true">
|
<div class="wrapper" @onclick="Open" @onclick:stopPropagation="true">
|
||||||
@if (Attachment.ContentType.StartsWith("image"))
|
@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")
|
// else if (Attachment.ContentType == "audio/x-mod")
|
||||||
// {
|
// {
|
||||||
|
@ -50,7 +51,7 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter] [EditorRequired] public required NoteAttachment Attachment { get; set; }
|
[Parameter] [EditorRequired] public required NoteAttachment Attachment { get; set; }
|
||||||
[Parameter] [EditorRequired] public required EventCallback OnOpen { get; set; }
|
[Parameter] [EditorRequired] public required EventCallback<NoteAttachment> OnOpen { get; set; }
|
||||||
|
|
||||||
private bool BlurImage { get; set; }
|
private bool BlurImage { get; set; }
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OnOpen.InvokeAsync();
|
OnOpen.InvokeAsync(Attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,12 @@
|
||||||
await Module.InvokeVoidAsync("scrollTo", _refs[Focused]);
|
await Module.InvokeVoidAsync("scrollTo", _refs[Focused]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task OpenDialog()
|
public async Task OpenDialog(NoteAttachment attachment)
|
||||||
{
|
{
|
||||||
await Module.InvokeVoidAsync("openDialog", Dialog);
|
await Module.InvokeVoidAsync("openDialog", Dialog);
|
||||||
ScrollWidth = await Module.InvokeAsync<int>("getScrollWidth", Scroller);
|
ScrollWidth = await Module.InvokeAsync<int>("getScrollWidth", Scroller);
|
||||||
|
var index = Attachments.IndexOf(attachment);
|
||||||
|
await Module.InvokeVoidAsync("scrollTo", _refs[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CloseDialog()
|
private async Task CloseDialog()
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
[Parameter] [EditorRequired] public required IList<NoteAttachment> Attachments { get; set; }
|
[Parameter] [EditorRequired] public required IList<NoteAttachment> Attachments { get; set; }
|
||||||
private AttachmentView View { get; set; } = null!;
|
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