Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #48 from pvdthings/fix-chooser-body-scroll
Browse files Browse the repository at this point in the history
Prevent body scrolling when chooser (mobile) is open
  • Loading branch information
dillonfagan authored Aug 22, 2023
2 parents 6196520 + f39068f commit 8865f32
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/components/Chooser/Chooser.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
let chosenOption = options[0];
let dropdownHidden = true;
let innerWidth: number;
$: isEnglish = $locale === 'en';
const dispatch = createEventDispatcher();
const toggleDropdown = () => {
dropdownHidden = !dropdownHidden;
if (innerWidth < 768) {
document.body.classList.toggle('overflow-hidden');
} else {
document.body.classList.remove('overflow-hidden');
}
};
const optionChosen = (option) => {
Expand All @@ -25,7 +32,7 @@
};
</script>

<svelte:window on:click={() => (dropdownHidden = true)} />
<svelte:window bind:innerWidth on:click={() => (dropdownHidden = true)} />

<div class="relative h-11" on:click|stopPropagation={() => {}} on:keypress={() => {}}>
<button
Expand Down

0 comments on commit 8865f32

Please sign in to comment.