-
- {currentIndex + 1}/{images.length}
-
-
-
-
{
- setCurrentIndex((old) => (old > 0 ? old - 1 : old));
- }}
- >
-
+ visible={visible}
+ className="z-[1002] h-screen flex justify-center items-center"
+ onMaskClick={() => {
+ setVisible(false), setImages([]), setCurrentIndex(0);
+ // root.unmount();
+ }}
+ >
+
+
+ {currentIndex + 1}/{images.length}
{
- setCurrentIndex((old) =>
- old < images.length - 1 ? old + 1 : old
- );
+ setVisible(false), setImages([]), setCurrentIndex(0);
+ // root.unmount();
}}
>
-
+
+
+
+
{
+ setCurrentIndex((old) => (old > 0 ? old - 1 : old));
+ }}
+ >
+
+
+
{
+ setCurrentIndex((old) =>
+ old < images.length - 1 ? old + 1 : old
+ );
+ setInitialX((currentIndex || 1) * window.innerWidth * 2);
+ }}
+ >
+
+
-
-
+
);
}
diff --git a/components/Photos/index.js b/components/Photos/index.js
index 9e5f922..a696323 100644
--- a/components/Photos/index.js
+++ b/components/Photos/index.js
@@ -8,7 +8,7 @@ import { useRouter } from "next/navigation";
import baseRequest from "@/utils/baseRequest";
import { handleShowVideo } from "@/utils/tools/handleFuns";
// import dynamic from 'next/dynamic'
-// import ImagesMask from "@/components/ImagesMask";
+import ImagesMask from "@/components/ImagesMask";
// const ImagesMask = dynamic(() =>
// import('@/components/ImagesMask'), { ssr: false }
// )
@@ -84,15 +84,15 @@ export default function Photos({
}, []);
const showPhotos = (photos, index) => {
currentIndex.current = index;
- const interval = setInterval(() => {
- const bodyBox = document.getElementsByClassName("photos-bodyBox")[0];
- if (bodyBox) {
- bodyBox.firstChild.lastChild.style.transform = `translateX(-${
- currentIndex.current * (window.innerWidth + 16)
- }px)`;
- // console.log(bodyBox.firstChild.lastChild.style.transform);
- }
- }, 400);
+ // const interval = setInterval(() => {
+ // const bodyBox = document.getElementsByClassName("photos-bodyBox")[0];
+ // if (bodyBox) {
+ // bodyBox.firstChild.lastChild.style.transform = `translateX(-${
+ // currentIndex.current * (window.innerWidth + 16)
+ // }px)`;
+ // // console.log(bodyBox.firstChild.lastChild.style.transform);
+ // }
+ // }, 400);
// 添加左右切换按钮
// const btns = document.createElement("div");
@@ -129,65 +129,62 @@ export default function Photos({
// });
// btns.append(btnL, btnR);
// handleShowImages(index, photos, btns,interval);
- handleShowImages(index, photos, interval);
+ // handleShowImages(index, photos, interval);
// setVisible(true)
- // console.log(imagesMaskRef.current);
- // imagesMaskRef.current.show(
- // photos.map((item) => item?.url),
- // index
- // );
+ console.log(imagesMaskRef.current, photos);
+ imagesMaskRef.current.show(photos, index, data);
};
- const handleShowImages = (index, photos, interval) => {
- const mediaDom = document.createElement("div");
- mediaDom.style.width = "100vw";
- document.body.appendChild(mediaDom);
- mediaDom.className = `${
- photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom"
- }`;
- // mediaDom.appendChild(btns);
- document.body.style.overflow = "hidden";
- ImageViewer.clear();
- ImageViewer.Multi.show({
- images: photos.map((item) => item?.url),
- defaultIndex: index,
- renderFooter: (image, index) => {
- return renderFooter(photos[index]?.type == "hid", mediaDom);
- },
+ // const handleShowImages = (index, photos, interval) => {
+ // const mediaDom = document.createElement("div");
+ // mediaDom.style.width = "100vw";
+ // document.body.appendChild(mediaDom);
+ // mediaDom.className = `${
+ // photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom"
+ // }`;
+ // // mediaDom.appendChild(btns);
+ // document.body.style.overflow = "hidden";
+ // ImageViewer.clear();
+ // ImageViewer.Multi.show({
+ // images: photos.map((item) => item?.url),
+ // defaultIndex: index,
+ // renderFooter: (image, index) => {
+ // return renderFooter(photos[index]?.type == "hid", mediaDom);
+ // },
- getContainer: mediaDom,
- onIndexChange: (index) => {
- currentIndex.current = index;
- mediaDom.className = `${
- photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom"
- }`;
- const leftBtn = document.getElementsByClassName(
- "imagesBtnsControllerLeft"
- )[0];
- const rightBtn = document.getElementsByClassName(
- "imagesBtnsControllerRight"
- )[0];
- if (leftBtn && rightBtn) {
- if (!index) {
- leftBtn.style.opacity = 0.5;
- rightBtn.style.opacity = 1;
- } else if (index == currentPhotos.length - 1) {
- leftBtn.style.opacity = 1;
- rightBtn.style.opacity = 0.5;
- } else {
- leftBtn.style.opacity = 1;
- rightBtn.style.opacity = 1;
- }
- }
- },
- afterClose: () => {
- mediaDom.remove();
- clearInterval(interval);
- document.body.style.overflow = "auto";
- },
- classNames: { body: "photos-bodyBox" },
- });
- };
+ // getContainer: mediaDom,
+ // onIndexChange: (index) => {
+ // currentIndex.current = index;
+ // mediaDom.className = `${
+ // photos[index]?.type == "hid" ? "mediaDom photos-body" : "mediaDom"
+ // }`;
+ // const leftBtn = document.getElementsByClassName(
+ // "imagesBtnsControllerLeft"
+ // )[0];
+ // const rightBtn = document.getElementsByClassName(
+ // "imagesBtnsControllerRight"
+ // )[0];
+ // if (leftBtn && rightBtn) {
+ // if (!index) {
+ // leftBtn.style.opacity = 0.5;
+ // rightBtn.style.opacity = 1;
+ // } else if (index == currentPhotos.length - 1) {
+ // leftBtn.style.opacity = 1;
+ // rightBtn.style.opacity = 0.5;
+ // } else {
+ // leftBtn.style.opacity = 1;
+ // rightBtn.style.opacity = 1;
+ // }
+ // }
+ // },
+ // afterClose: () => {
+ // mediaDom.remove();
+ // clearInterval(interval);
+ // document.body.style.overflow = "auto";
+ // },
+ // classNames: { body: "photos-bodyBox" },
+ // });
+ // };
const handleSeeAllPhotos = (e) => {
e.stopPropagation();
e.preventDefault();
@@ -343,7 +340,7 @@ export default function Photos({
);
})}
- {/*