[frontend/components] Keyboard navigation for AttachmentViewer (ISH-641)

This commit is contained in:
Lilian 2024-11-28 21:33:53 +01:00
parent e70cb01c5b
commit 6edfc66c3e
No known key found for this signature in database

View file

@ -2,7 +2,7 @@
@using Iceshrimp.Shared.Schemas.Web
@inject IJSRuntime Js
<dialog class="attachment-view" @ref="Dialog">
<dialog class="attachment-view" @onkeydown="OnKeyDown" @ref="Dialog">
<button @onclick="CloseDialog" @onclick:stopPropagation="true" class="close">
<Icon Name="Icons.X" Size="5rem"></Icon>
</button>
@ -40,6 +40,19 @@
set => _refs.Add(value);
}
private async Task OnKeyDown(KeyboardEventArgs e)
{
switch (e.Key)
{
case "ArrowRight":
await Next();
break;
case "ArrowLeft":
await Prev();
break;
}
}
private ElementReference Scroller { get; set; }
private int ScrollWidth { get; set; }
private int ScrollLeft { get; set; }