Skip to content

Commit

Permalink
fix: fullscreen not opening correct post
Browse files Browse the repository at this point in the history
  • Loading branch information
kurozenzen committed Jan 27, 2024
1 parent a21c33a commit 4712761
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,14 @@
const dispatch = createEventDispatcher();
const focusCurrent = () => {
if (current) {
current.scrollIntoView();
current.scrollLeft = 0;
}
};
const onScroll = (event: UIEvent) => {
const target = event.target as HTMLDivElement;
const height = target.getBoundingClientRect().height;
const newIndex = target.scrollTop / height;
const roundedIndex = Math.round(newIndex);
if (roundedIndex != index) {
requestAnimationFrame(() => {
const onScroll = (event: Event) => {
requestAnimationFrame(() => {
const target = event.target as HTMLDivElement;
const height = target.getBoundingClientRect().height;
const newIndex = target.scrollTop / height;
const roundedIndex = Math.round(newIndex);
if (roundedIndex != index) {
index = roundedIndex;
postCurrent = $results.posts[index];
postPrevious = index > 0 ? $results.posts[index - 1] : undefined;
Expand All @@ -45,8 +38,8 @@
if (current) {
current.scrollLeft = 0;
}
});
}
}
});
};
const keybinds = (event: KeyboardEvent) => {
Expand Down Expand Up @@ -80,8 +73,11 @@
};
onMount(() => {
if (current) {
current.scrollIntoView(true);
current.scrollLeft = 0;
}
document.addEventListener('keydown', keybinds);
focusCurrent();
});
onDestroy(() => {
document.removeEventListener('keydown', keybinds);
Expand Down
6 changes: 5 additions & 1 deletion src/lib/components/pure/fullscreen/Fullscreen.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
};
let dialog: HTMLDivElement;
let ready = false;
onMount(async () => {
dialog.focus();
Expand All @@ -24,6 +25,7 @@
} catch {
// ignored
}
ready = true;
});
onDestroy(async () => {
Expand All @@ -43,7 +45,9 @@
on:click|stopPropagation={() => {}}
on:keydown={closeOnEscapePressed}
>
<slot />
{#if ready}
<slot />
{/if}
</div>

<style>
Expand Down
1 change: 0 additions & 1 deletion src/lib/logic/share-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createSearchableTag } from './tag-utils';
const DELIMITER = ';';

export const parseShareTags = (value: string): kurosearch.SearchableTag[] => {
debugger;
return value
.replaceAll(' ', '+')
.split(DELIMITER)
Expand Down

0 comments on commit 4712761

Please sign in to comment.