compass
This commit is contained in:
@@ -1,13 +1,17 @@
|
|||||||
import useModal from "../../store/useModal";
|
import useModal from "../../store/useModal";
|
||||||
|
import useSequence from "../../store/useSequence";
|
||||||
import Button from "../Button";
|
import Button from "../Button";
|
||||||
import DisclaimerIcon from "../icons/DisclaimerIcon";
|
import DisclaimerIcon from "../icons/DisclaimerIcon";
|
||||||
import DisclaimerModal from "../modals/DisclaimerModal";
|
import DisclaimerModal from "../modals/DisclaimerModal";
|
||||||
|
|
||||||
const ButtomPanel = () => {
|
const ComplexButtomPanel = () => {
|
||||||
const { setModal } = useModal();
|
const { setModal } = useModal();
|
||||||
|
const { currentCompassRotate } = useSequence();
|
||||||
|
|
||||||
const handleOnDisclaimerClick = () => {
|
const handleOnDisclaimerClick = () => {
|
||||||
setModal(<DisclaimerModal />);
|
setModal(<DisclaimerModal />);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="absolute z-20 bottom-0 left-0 w-full select-none touch-none pointer-events-none flex gap-2 justify-between items-end">
|
<div className="absolute z-20 bottom-0 left-0 w-full select-none touch-none pointer-events-none flex gap-2 justify-between items-end">
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
@@ -25,9 +29,10 @@ const ButtomPanel = () => {
|
|||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<div className="bg-[#0D192266] rounded-full backdrop-blur-sm">
|
<div className="bg-[#0D192266] rounded-full backdrop-blur-sm">
|
||||||
<img
|
<img
|
||||||
|
style={{ transform: `rotate(${currentCompassRotate - 180}deg)` }}
|
||||||
src="../images/masterplan/compass.png"
|
src="../images/masterplan/compass.png"
|
||||||
alt="compass"
|
alt="compass"
|
||||||
className=""
|
className="transition-transform duration-[750ms] ease-in-out"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -35,4 +40,4 @@ const ButtomPanel = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ButtomPanel;
|
export default ComplexButtomPanel;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const FloorLayout = () => {
|
const FloorLayout = () => {
|
||||||
return <></>;
|
return <div></div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default FloorLayout;
|
export default FloorLayout;
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import { isMobile } from "react-device-detect";
|
|||||||
import { useSwipeable } from "react-swipeable";
|
import { useSwipeable } from "react-swipeable";
|
||||||
import { Transition } from "react-transition-group";
|
import { Transition } from "react-transition-group";
|
||||||
import Button from "../Button";
|
import Button from "../Button";
|
||||||
import ActiveResizeIcon from "../icons/ActiveResizeIcon";
|
|
||||||
import LeftArrowSliderIcon from "../icons/LeftArrowSliderIcon";
|
import LeftArrowSliderIcon from "../icons/LeftArrowSliderIcon";
|
||||||
import RightArrowSliderIcon from "../icons/RightArrowSliderIcon";
|
import RightArrowSliderIcon from "../icons/RightArrowSliderIcon";
|
||||||
|
import useSequence from "../../store/useSequence";
|
||||||
|
|
||||||
// const marks = [
|
// const marks = [
|
||||||
// {
|
// {
|
||||||
@@ -54,26 +54,32 @@ interface SequenceSliderProps {
|
|||||||
function SequenceSlider({ path }: SequenceSliderProps) {
|
function SequenceSlider({ path }: SequenceSliderProps) {
|
||||||
const [selectedImageRightIndex, setSelectedRightImageIndex] =
|
const [selectedImageRightIndex, setSelectedRightImageIndex] =
|
||||||
useState<number>(keyframes[3]);
|
useState<number>(keyframes[3]);
|
||||||
const [selectedImageLeftIndex, setSelectedImageLeftIndex] = useState<number>(
|
const [selectedImageLeftKeyframe, setSelectedImageLeftKeyframe] =
|
||||||
arrayLength - keyframes[3]
|
useState<number>(arrayLength - keyframes[3]);
|
||||||
);
|
|
||||||
const [isAnimate, setIsAnimate] = useState<boolean>(false);
|
const [isAnimate, setIsAnimate] = useState<boolean>(false);
|
||||||
|
const [loadedImages, setLoadedImages] = useState<number>(0);
|
||||||
const [keyframeIndex, setKeyframeIndex] = useState<number>(3);
|
const [keyframeIndex, setKeyframeIndex] = useState<number>(3);
|
||||||
|
const { setCurrentCompassRotate, currentCompassRotate } = useSequence();
|
||||||
|
const [width, setWidth] = useState<number>();
|
||||||
|
const [top, setTop] = useState<number>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCurrentCompassRotate(keyframes[3]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handlers = useSwipeable({
|
const handlers = useSwipeable({
|
||||||
trackMouse: true,
|
trackMouse: true,
|
||||||
onSwipedLeft: () => !isAnimate && next(),
|
onSwipedLeft: () => !isAnimate && next(),
|
||||||
onSwipedRight: () => !isAnimate && prev(),
|
onSwipedRight: () => !isAnimate && prev(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const [loadedImages, setLoadedImages] = useState<number>(0);
|
|
||||||
|
|
||||||
function handleLoad() {
|
function handleLoad() {
|
||||||
setLoadedImages((prev) => prev + 1);
|
setLoadedImages((prev) => prev + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function animateToRight(currentOffset: number) {
|
function animateToRight(currentOffset: number) {
|
||||||
const obj = { selectedImageIndex: selectedImageRightIndex };
|
const obj = { selectedImageIndex: selectedImageRightIndex };
|
||||||
|
setCurrentCompassRotate(currentCompassRotate + currentOffset);
|
||||||
|
|
||||||
gsap.to(obj, {
|
gsap.to(obj, {
|
||||||
selectedImageIndex: selectedImageRightIndex + currentOffset,
|
selectedImageIndex: selectedImageRightIndex + currentOffset,
|
||||||
@@ -81,12 +87,15 @@ function SequenceSlider({ path }: SequenceSliderProps) {
|
|||||||
ease: "power1.inOut",
|
ease: "power1.inOut",
|
||||||
onUpdate: () => {
|
onUpdate: () => {
|
||||||
const roundedIndex = Math.round(obj.selectedImageIndex);
|
const roundedIndex = Math.round(obj.selectedImageIndex);
|
||||||
|
|
||||||
if (roundedIndex >= arrayLength) {
|
if (roundedIndex >= arrayLength) {
|
||||||
setSelectedRightImageIndex(roundedIndex - arrayLength);
|
setSelectedRightImageIndex(roundedIndex - arrayLength);
|
||||||
setSelectedImageLeftIndex(arrayLength - (roundedIndex - arrayLength));
|
setSelectedImageLeftKeyframe(
|
||||||
|
arrayLength - (roundedIndex - arrayLength)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
setSelectedRightImageIndex(roundedIndex);
|
setSelectedRightImageIndex(roundedIndex);
|
||||||
setSelectedImageLeftIndex(arrayLength - roundedIndex);
|
setSelectedImageLeftKeyframe(arrayLength - roundedIndex);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
@@ -96,21 +105,23 @@ function SequenceSlider({ path }: SequenceSliderProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function animateToLeft(currentOffset: number) {
|
function animateToLeft(currentOffset: number) {
|
||||||
const obj = { selectedImageIndex: selectedImageLeftIndex };
|
const obj = { selectedImageIndex: selectedImageLeftKeyframe };
|
||||||
|
setCurrentCompassRotate(currentCompassRotate - currentOffset);
|
||||||
|
|
||||||
gsap.to(obj, {
|
gsap.to(obj, {
|
||||||
selectedImageIndex: selectedImageLeftIndex + currentOffset,
|
selectedImageIndex: selectedImageLeftKeyframe + currentOffset,
|
||||||
duration: 0.75,
|
duration: 0.75,
|
||||||
ease: "power1.inOut",
|
ease: "power1.inOut",
|
||||||
onUpdate: () => {
|
onUpdate: () => {
|
||||||
const roundedIndex = Math.round(obj.selectedImageIndex);
|
const roundedIndex = Math.round(obj.selectedImageIndex);
|
||||||
|
|
||||||
if (roundedIndex > arrayLength) {
|
if (roundedIndex > arrayLength) {
|
||||||
setSelectedRightImageIndex(
|
setSelectedRightImageIndex(
|
||||||
arrayLength - (roundedIndex - arrayLength)
|
arrayLength - (roundedIndex - arrayLength)
|
||||||
);
|
);
|
||||||
setSelectedImageLeftIndex(roundedIndex - arrayLength);
|
setSelectedImageLeftKeyframe(roundedIndex - arrayLength);
|
||||||
} else {
|
} else {
|
||||||
setSelectedImageLeftIndex(roundedIndex);
|
setSelectedImageLeftKeyframe(roundedIndex);
|
||||||
setSelectedRightImageIndex(arrayLength - roundedIndex);
|
setSelectedRightImageIndex(arrayLength - roundedIndex);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -148,9 +159,6 @@ function SequenceSlider({ path }: SequenceSliderProps) {
|
|||||||
animateToLeft(currentOffset);
|
animateToLeft(currentOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [width, setWidth] = useState<number>();
|
|
||||||
const [top, setTop] = useState<number>();
|
|
||||||
|
|
||||||
function handleResize() {
|
function handleResize() {
|
||||||
setWidth(window.innerWidth);
|
setWidth(window.innerWidth);
|
||||||
setTop(window.innerWidth / 2 - window.innerHeight / 2);
|
setTop(window.innerWidth / 2 - window.innerHeight / 2);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import ButtomPanel from "../components/ButtomPanel";
|
import ComplexButtomPanel from "../components/complexPage/ComplexButtomPanel";
|
||||||
import ComplexTopPanel from "../components/complexPage/ComplexTopPanel";
|
import ComplexTopPanel from "../components/complexPage/ComplexTopPanel";
|
||||||
import SequenceSlider from "../components/complexPage/SequenceSlider";
|
import SequenceSlider from "../components/complexPage/SequenceSlider";
|
||||||
|
|
||||||
@@ -8,7 +8,8 @@ const Complex = () => {
|
|||||||
<ComplexTopPanel />
|
<ComplexTopPanel />
|
||||||
<div className="bg-blue-500 h-full w-full"></div>
|
<div className="bg-blue-500 h-full w-full"></div>
|
||||||
<SequenceSlider path={"/images/sequence"} />
|
<SequenceSlider path={"/images/sequence"} />
|
||||||
<ButtomPanel />
|
{/* <ButtomPanel /> */}
|
||||||
|
<ComplexButtomPanel />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { create } from "zustand";
|
||||||
|
|
||||||
|
interface SequenceStore {
|
||||||
|
currentCompassRotate: number;
|
||||||
|
setCurrentCompassRotate: (keyframe: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const useSequence = create<SequenceStore>((set) => ({
|
||||||
|
currentCompassRotate: 0,
|
||||||
|
setCurrentCompassRotate: (keyframe) =>
|
||||||
|
set(() => ({ currentCompassRotate: keyframe })),
|
||||||
|
}));
|
||||||
|
|
||||||
|
export default useSequence;
|
||||||
Reference in New Issue
Block a user