Skip to content

Commit

Permalink
Merge pull request #78 from G-Techs/fix/carousel
Browse files Browse the repository at this point in the history
fix: fix carousel not scrolling on first render
  • Loading branch information
Muhindo-Galien authored Dec 30, 2022
2 parents 30a6053 + 8dc60b5 commit 85d2027
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
8 changes: 2 additions & 6 deletions components/modules/FeaturedAlbum/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ const FeaturedAlbum = () => {
title="Featured Albums"
className="mt-8 p-4 rounded-lg shadow-lg mr-4 bg-white"
>
{data.map((song) => {
return (
<>
<FeaturedAlbumCard album={song} />
</>
);
{data.map((song, index) => {
return <FeaturedAlbumCard album={song} key={index} />;
})}
</Carousel>
);
Expand Down
6 changes: 2 additions & 4 deletions components/modules/__modules__/Carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const Carousel: FC<CarouselProps> = ({
scrollContainer.current,
40,
200,
scrollContainer.current?.offsetWidth
? -scrollContainer.current?.offsetWidth
: 0
-(scrollContainer.current?.offsetWidth as number)
);
};

Expand All @@ -34,7 +32,7 @@ const Carousel: FC<CarouselProps> = ({
scrollContainer.current,
40,
200,
scrollContainer.current?.offsetWidth
scrollContainer.current?.offsetWidth as number
);
};
return (
Expand Down
10 changes: 4 additions & 6 deletions components/modules/hooks/useSideScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ const useSideScroll = () => {
let scrollAmount = 0;

const slideTimer = setInterval(() => {
if (element?.scrollLeft) {
element.scrollLeft += step;
scrollAmount += Math.abs(step);
if (scrollAmount >= distance) {
clearInterval(slideTimer);
}
element!.scrollLeft += step as number;
scrollAmount += Math.abs(step as number);
if (scrollAmount >= distance) {
clearInterval(slideTimer);
}
}, speed);
};
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"components/modules/__modules__/_Vectors/wavePlayVector.jsx",
"components/modules/AddNewSinger/index.tsx",
"components/modules/utils/config/audioPlayer.tsx",
"components/modules/utils/config/audioControls.tsx"
"components/modules/utils/config/audioControls.tsx",
"components/modules/__modules__/Carousel/index.jsx"
],
"exclude": ["node_modules"]
}

1 comment on commit 85d2027

@vercel
Copy link

@vercel vercel bot commented on 85d2027 Dec 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

yokaa-frontend – ./

yokaa-frontend-git-main-yokaa.vercel.app
yokaa-frontend-yokaa.vercel.app
yokaa-frontend.vercel.app

Please sign in to comment.