diff --git a/src/components/Histories.tsx b/src/components/Histories.tsx
index e2ef928..f1be718 100644
--- a/src/components/Histories.tsx
+++ b/src/components/Histories.tsx
@@ -1,32 +1,48 @@
-import { createRef, useEffect, useLayoutEffect, useState } from "react";
+import { createRef, useEffect, useLayoutEffect, useRef, useState } from "react";
import { useSwipeable } from "react-swipeable";
import ArrowLeftIcon from "./icons/ArrowLeftIcon";
import ArrowRightIcon from "./icons/ArrowRightIcon";
import { Transition } from "react-transition-group";
+import { motion } from "framer-motion";
+
+interface IVideo {
+ id: number;
+ src: string;
+ title: string;
+ desc: string;
+}
const CARD_COUNT = 3;
-const videos = [
+const videos: IVideo[] = [
{
id: 1,
- src: "videos/video.mp4",
- title: "Вся информация о жилом комплексе на одном экране",
- desc: "Инструмент продаж graff.estate для проекта LIFE RESIDENCE: новый подход к презентации недвижимости",
+ src: "/videos/histories/1.mp4",
+ title: "",
+ desc: "",
},
{
id: 2,
- src: "videos/video.mp4",
- title: "Говно",
- desc: "Жопа",
+ src: "/videos/histories/2.mp4",
+ title: "",
+ desc: "",
},
{
id: 3,
- src: "videos/video.mp4",
- title: "И в",
- desc: "прод",
+ src: "/videos/histories/3.mp4",
+ title: "",
+ desc: "",
},
];
const Histories = () => {
+ const [isViewportEntered, setIsViewportEntered] = useState
(false);
+ // const [videos, setVideos] = useState([]);
+
+ function handleViewportEnter() {
+ if (isViewportEntered) return;
+ setIsViewportEntered(true);
+ }
+
const [offset, setOffset] = useState(0);
const [videoRefs, setVideoRefs] = useState<
React.RefObject[]
@@ -96,7 +112,7 @@ const Histories = () => {
video.current.pause();
}
});
- }, [videoRefs, selectedVideo]);
+ }, [videoRefs, selectedVideo, isViewportEntered]);
useEffect(() => {
const currentVideoRef = videoRefs[selectedVideo];
@@ -124,7 +140,10 @@ const Histories = () => {
}, [selectedVideo, videoRefs]);
return (
-
+
@@ -188,7 +207,7 @@ const Histories = () => {
>
-
+
- Вся информация о жилом комплексе на одном экране
+ {videos[selectedVideo].title}
- Инструмент продаж graff.estate для проекта LIFE RESIDENCE: новый
- подход к презентации недвижимости
+ {videos[selectedVideo].desc}
@@ -241,7 +259,7 @@ const Histories = () => {
-