|
|
|
@ -10,11 +10,35 @@ export default function Page2({ list, page }) { |
|
|
|
|
translateX: null, |
|
|
|
|
rotate: null, |
|
|
|
|
}); |
|
|
|
|
const [mobilePosition, setMobilePosition] = useState(null); |
|
|
|
|
useEffect(() => { |
|
|
|
|
setMobilePosition( |
|
|
|
|
boxPositionFormula( |
|
|
|
|
window.scrollY > 3 * height ? 3 * height : window.scrollY, |
|
|
|
|
-(window.innerHeight * 7) / 20, |
|
|
|
|
1.37, |
|
|
|
|
"increase" |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
setBoxPosition({ |
|
|
|
|
translateY: boxPositionFormula(window.scrollY, 5, 7, "increase"), |
|
|
|
|
translateX: boxPositionFormula(window.scrollY, 5, 7, "increase"), |
|
|
|
|
rotate: boxPositionFormula(window.scrollY, 5, 10, "decrease"), |
|
|
|
|
translateY: boxPositionFormula( |
|
|
|
|
window.scrollY > 2 * height ? 2 * height : window.scrollY, |
|
|
|
|
5, |
|
|
|
|
7, |
|
|
|
|
"increase" |
|
|
|
|
), |
|
|
|
|
translateX: boxPositionFormula( |
|
|
|
|
window.scrollY > 2 * height ? 2 * height : window.scrollY, |
|
|
|
|
-12, |
|
|
|
|
1.5, |
|
|
|
|
"increase" |
|
|
|
|
), |
|
|
|
|
rotate: boxPositionFormula( |
|
|
|
|
window.scrollY > 2 * height ? 2 * height : window.scrollY, |
|
|
|
|
5, |
|
|
|
|
10, |
|
|
|
|
"decrease" |
|
|
|
|
), |
|
|
|
|
}); |
|
|
|
|
window.addEventListener("scroll", (e) => { |
|
|
|
|
setTop(scroll.homeScrollHandler(page)); |
|
|
|
@ -27,7 +51,7 @@ export default function Page2({ list, page }) { |
|
|
|
|
if (scrollY <= height) { |
|
|
|
|
setBoxPosition({ |
|
|
|
|
translateY: 5, |
|
|
|
|
translateX: -12, |
|
|
|
|
translateX: -15, |
|
|
|
|
rotate: 5, |
|
|
|
|
}); |
|
|
|
|
} else if (scrollY > height && scrollY <= 2 * height) { |
|
|
|
@ -46,19 +70,46 @@ export default function Page2({ list, page }) { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const mobilePositionHandler = (scrollY) => {}; |
|
|
|
|
const mobilePositionHandler = (scrollY) => { |
|
|
|
|
if (scrollY <= 2 * height) { |
|
|
|
|
setMobilePosition(-70); |
|
|
|
|
} else if (scrollY > 2 * height && scrollY <= 3 * height) { |
|
|
|
|
setMobilePosition( |
|
|
|
|
boxPositionFormula( |
|
|
|
|
scrollY - height, |
|
|
|
|
(-(window.innerHeight * 7) / 20 / window.innerWidth) * 100, |
|
|
|
|
1.3, |
|
|
|
|
"increase" |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const boxPositionFormula = (scrollY, first, speed, direction) => { |
|
|
|
|
console.log(scrollY); |
|
|
|
|
if (direction === "increase") { |
|
|
|
|
return first + (((scrollY - height) / scrollY) * 100) / speed; |
|
|
|
|
} else { |
|
|
|
|
return first - (((scrollY - height) / scrollY) * 100) / speed; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// const mobilePositionFormula = (scrollY) => {
|
|
|
|
|
// return - + ((scrollY - 2 * height) / height * 100);
|
|
|
|
|
// };
|
|
|
|
|
return ( |
|
|
|
|
<div |
|
|
|
|
className={_.join(["home-page2 h-screen w-full fixed left-0"], " ")} |
|
|
|
|
style={{ top: top }} |
|
|
|
|
className={_.join(["home-page2 h-screen w-full fixed left-0 origin-top"], " ")} |
|
|
|
|
style={{ |
|
|
|
|
top: top, |
|
|
|
|
transform: `rotateX(${ |
|
|
|
|
window.scrollY > 0 |
|
|
|
|
? window.scrollY <= height |
|
|
|
|
? 90 - (window.scrollY / height) * 90 |
|
|
|
|
: 0 |
|
|
|
|
: 90 |
|
|
|
|
}deg)`,
|
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<div |
|
|
|
|
className={_.join( |
|
|
|
@ -73,6 +124,19 @@ export default function Page2({ list, page }) { |
|
|
|
|
> |
|
|
|
|
<div className="absolute left-4 top-4 h-40 w-40 bg-red-500"></div> |
|
|
|
|
</div> |
|
|
|
|
{/* mobile phone */} |
|
|
|
|
<div |
|
|
|
|
className="fixed border" |
|
|
|
|
style={{ |
|
|
|
|
top: "10%", |
|
|
|
|
height: (window.innerHeight * 7) / 10, |
|
|
|
|
width: (window.innerHeight * 7) / 20, |
|
|
|
|
left: mobilePosition + "%", |
|
|
|
|
// transform: `translateX(-${(window.innerHeight * 7) / 40 - 84}px)`,
|
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
{mobilePosition} |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|