Skip to content

Commit

Permalink
change to svelte:window
Browse files Browse the repository at this point in the history
  • Loading branch information
ieedan committed Aug 13, 2024
1 parent 6ffd896 commit 1db9759
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/lib/components/ui/tabs/tabs-list.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
let postBlur = false;
// When the tabs are scrolled it will determine whether or not to show the blur at the end
const scroll = () => {
const handle_blur = () => {
if (el.offsetWidth + el.scrollLeft < el.scrollWidth) {
postBlur = true;
} else {
Expand All @@ -32,15 +32,12 @@
};
onMount(() => {
scroll(); // initially determine blur state
el.addEventListener('scroll', scroll); // on:scroll listener doesn't work on TabsPrimitive
return () => {
el.removeEventListener('scroll', scroll);
};
handle_blur(); // initially determine blur state
});
</script>

<svelte:window on:scroll={handle_blur} on:resize={handle_blur}/>

<!-- Make sure you have the `no-scrollbar` class in your tailwind.config file -->

<TabsPrimitive.List
Expand Down

0 comments on commit 1db9759

Please sign in to comment.