mirror of
https://git.rdcenter.ru/RDCenter/skb-kit.git
synced 2026-12-05 06:29:45 +00:00
пофиксила партнёров в моб - карусель если > 1 лого
This commit is contained in:
1 parent
98f6b073a5
commit
cf6951447a
1 file changed
+18
-11
@@ -1,8 +1,8 @@
|
||||
import Marquee from "react-fast-marquee";
|
||||
|
||||
import { useMedia } from "@/modules/media/hooks/useMedia";
|
||||
import PartnersLogo from "./PartnersLogo";
|
||||
import styles from "./Partners.module.scss";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface Partner {
|
||||
src: string;
|
||||
@@ -13,21 +13,28 @@ interface Partner {
|
||||
|
||||
function Partners() {
|
||||
const { data: mediaData, isLoading, isError } = useMedia();
|
||||
const [isMobile, setIsMobile] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setIsMobile(window.innerWidth <= 768);
|
||||
};
|
||||
|
||||
// Проверяем сразу при загрузке
|
||||
handleResize();
|
||||
|
||||
// Добавляем слушатель изменения размера окна
|
||||
window.addEventListener('resize', handleResize);
|
||||
|
||||
// Убираем слушатель при размонтировании компонента
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
// Отфильтрованные партнёрские медиа
|
||||
const mediaList: Partner[] =
|
||||
mediaData?.filter((item: Partner) => item.category === "partners") || [];
|
||||
|
||||
if (isLoading) {
|
||||
return <div className={styles.loading}>Загрузка партнеров...</div>;
|
||||
}
|
||||
|
||||
if (isError || mediaList.length === 0) {
|
||||
return <div className={styles.error}>Не удалось загрузить партнеров</div>;
|
||||
}
|
||||
|
||||
// Определяем, нужно ли включать автопрокрутку
|
||||
const shouldAutoScroll = mediaList.length > 5;
|
||||
const shouldAutoScroll = isMobile ? mediaList.length > 1 : mediaList.length > 5;
|
||||
|
||||
if (isLoading) {
|
||||
return <div className={styles.loading}>Загрузка партнеров...</div>;
|
||||
|
||||
Reference in new issue
Block a user