|
|
@ -2,27 +2,56 @@ import React, { useState, useEffect } from "react"; |
|
|
|
import _ from "lodash"; |
|
|
|
import _ from "lodash"; |
|
|
|
import scroll from "../../../utils/scroll"; |
|
|
|
import scroll from "../../../utils/scroll"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function Page2({ list, page }) { |
|
|
|
export default function Page2({ list, page }) { |
|
|
|
const [top, setTop] = useState(window.innerHeight); |
|
|
|
const [top, setTop] = useState(window.innerHeight); |
|
|
|
|
|
|
|
const [boxPosition, setBoxPosition] = useState({ |
|
|
|
|
|
|
|
translateX : -12, |
|
|
|
|
|
|
|
translateY : 5, |
|
|
|
|
|
|
|
rotate : 5, |
|
|
|
|
|
|
|
}); |
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
window.addEventListener("scroll", (e) => { |
|
|
|
window.addEventListener("scroll", (e) => { |
|
|
|
setTop(scroll.homeScrollHandler(page)); |
|
|
|
setTop(scroll.homeScrollHandler(page)); |
|
|
|
|
|
|
|
boxPositionHandler(window.scrollY); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const height = window.innerHeight; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const boxPositionHandler = (scrollY) => { |
|
|
|
|
|
|
|
if(scrollY <= height){ |
|
|
|
|
|
|
|
setBoxPosition({ |
|
|
|
|
|
|
|
translateY : 5, |
|
|
|
|
|
|
|
translateX : -12, |
|
|
|
|
|
|
|
rotate : 5, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (scrollY > height && scrollY <= 2 * height) { |
|
|
|
|
|
|
|
setBoxPosition({ |
|
|
|
|
|
|
|
translateY : (-9 + (scrollY + height) / 154) > 12 ? 12 : (-9 + (scrollY + height) / 154), |
|
|
|
|
|
|
|
translateX : (-66 + (scrollY + height) / 40) > 15 ? 15 : (-66 + (scrollY + height) / 40), |
|
|
|
|
|
|
|
rotate : (-((scrollY + height) / 214) + 15) < 0 ? 0 : (-((scrollY + height) / 214) + 15), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
setBoxPosition({ |
|
|
|
|
|
|
|
translateY : 12, |
|
|
|
|
|
|
|
translateX : 15, |
|
|
|
|
|
|
|
rotate : 0, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
className={_.join(["home-page2 h-screen w-full fixed left-0"], " ")} |
|
|
|
|
|
|
|
style={{ top: top }} |
|
|
|
|
|
|
|
> |
|
|
|
<div |
|
|
|
<div |
|
|
|
className={_.join( |
|
|
|
className={_.join( |
|
|
|
[ |
|
|
|
["relative w-full h-full bg-blue-500 shadow-2xl transform"], |
|
|
|
"h-screen w-full pt-20 fixed left-0 bg-gray-200", |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
" " |
|
|
|
" " |
|
|
|
)} |
|
|
|
)} |
|
|
|
style={{ top: top }} |
|
|
|
style={{ transform: `translateX(${boxPosition.translateX}%) rotate(${boxPosition.rotate}deg) translateY(${boxPosition.translateY}%)` }} |
|
|
|
> |
|
|
|
></div> |
|
|
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|