mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-21 04:42:24 +00:00
fix editor picks carousels
This commit is contained in:
parent
a718b8048f
commit
6d2d7a2eed
3 changed files with 12 additions and 4 deletions
|
|
@ -52,7 +52,7 @@ export function LazyMediaCarousel({
|
||||||
}, [media, preloadedMedia]);
|
}, [media, preloadedMedia]);
|
||||||
|
|
||||||
const categoryName = title || category?.name || genre?.name || "";
|
const categoryName = title || category?.name || genre?.name || "";
|
||||||
const categorySlug = categoryName.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
const categorySlug = `${categoryName.toLowerCase().replace(/[^a-z0-9]+/g, "-")}-${mediaType}`;
|
||||||
|
|
||||||
// Test intersection observer
|
// Test intersection observer
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export function MediaCarousel({
|
||||||
carouselRefs,
|
carouselRefs,
|
||||||
}: MediaCarouselProps) {
|
}: MediaCarouselProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const categorySlug = category.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
const categorySlug = `${category.toLowerCase().replace(/[^a-z0-9]+/g, "-")}-${isTVShow ? "tv" : "movie"}`;
|
||||||
const browser = !!window.chrome;
|
const browser = !!window.chrome;
|
||||||
let isScrolling = false;
|
let isScrolling = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -290,9 +290,17 @@ export function DiscoverContent() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCategoryClick = (id: string, name: string) => {
|
const handleCategoryClick = (id: string, name: string) => {
|
||||||
const categorySlug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
// Try both movie and tv versions of the category slug
|
||||||
const element = document.getElementById(`carousel-${categorySlug}`);
|
const categorySlugBase = name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
||||||
|
const movieElement = document.getElementById(
|
||||||
|
`carousel-${categorySlugBase}-movie`,
|
||||||
|
);
|
||||||
|
const tvElement = document.getElementById(
|
||||||
|
`carousel-${categorySlugBase}-tv`,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Scroll to the first element that exists
|
||||||
|
const element = movieElement || tvElement;
|
||||||
if (element) {
|
if (element) {
|
||||||
element.scrollIntoView({
|
element.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue