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