Screen Recording 2023-01-16 at 1.15.15 AM.mov
왓챠 연말결산은 왓챠의 마케팅 이벤트로 한 해동안 왓챠를 이용한 유저들의 유의미한 데이터를 뽑아 추억을 되돌아 볼 수 있어요. 그리고 새로운 프로모션 이벤트를 보여주고 SNS로 공유시켜요.
제작 기간
2022년 12월 (약 한 달)
맡은 포지션
기술 스택
next js
typescript
고민했던 것
애니메이션 발생 시점
IntersectionObserver
로 지금 화면이 보이고 있는지를 판단.dispatchEvent
하고, 해당 이벤트는 callback 함수를 실행함.// addViewedCallback useEffect 예시
useEffect(() => {
let haveBeenViewed = false;
const io = new IntersectionObserver(entries => {
if (!ref.current) {
throw new Error("Ref should not be null");
}
if (haveBeenViewed) {
return;
}
const isVisible = !!entries.find(
entry => entry.isIntersecting && entry.target.id === ref.current?.id,
);
if (!isVisible) {
return;
}
haveBeenViewed = true;
ref.current.dispatchEvent(onViewEvent);
});
if (ref.current) {
io.observe(ref.current);
}
return () => {
io.disconnect();
};
}, []);
좋은 점