Skip to content

Commit

Permalink
Fix resizable and scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluesmile82 committed Oct 15, 2024
1 parent 9a2cb5f commit 669f328
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/section-2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,23 @@ export default function Section2() {
target: scrollSectionRef,
});
const [globePhase, setGlobePhase] = useState(0);
const [resizableWidth, setResizableWidth] = useState(400);

const screenWidth = useScreenWidthWithResize();
const [resizableWidth, setResizableWidth] = useState(screenWidth ? screenWidth / 2 : 800);

useEffect(() => {
scrollToSection(`globe-phase-${globePhase + 1}`);
if (globePhase) {
scrollToSection(`globe-phase-${globePhase + 1}`);
}
}, [globePhase]);

useEffect(() => {
if (screenWidth || resizableWidth === 0) {
setResizableWidth(screenWidth / 2);
}
}
, [screenWidth]);

useMotionValueEvent(scrollYProgress, "change", (latest) => {
if (latest >= 0 && latest < 0.1 && globePhase !== 0) {
setGlobePhase(0);
Expand Down

0 comments on commit 669f328

Please sign in to comment.