Fix gallery thumbnails bar not scrolling on click

Closes #104
This commit is contained in:
space-nuko
2023-06-01 19:41:18 -05:00
parent 4923a78d7c
commit d07d1e7478
2 changed files with 4 additions and 4 deletions

View File

@@ -15,7 +15,7 @@
export let label: string;
export let root: string = "";
export let root_url: null | string = null;
export let scrollOnUpdate = false;
export let focusOnScroll = false;
export let value: Array<string> | Array<FileData> | null = null;
export let style: Styles = {
grid_cols: [2],
@@ -121,11 +121,11 @@
let container: HTMLDivElement;
async function scroll_to_img(index: number | null) {
if (!scrollOnUpdate) return;
if (typeof index !== "number") return;
await tick();
el[index].focus();
if (focusOnScroll)
el[index].focus();
const { left: container_left, width: container_width } =
container.getBoundingClientRect();